From 9dc2835186d0fa22a5da5674c0c3f108aa4d54ee Mon Sep 17 00:00:00 2001 From: peper0 Date: Wed, 17 Apr 2024 02:25:03 +0200 Subject: [PATCH 1/8] Add support for 2 gang relay TS000F from _TZ3000_m8f3z8ju --- zhaquirks/tuya/ts000f_switch.py | 92 +++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/zhaquirks/tuya/ts000f_switch.py b/zhaquirks/tuya/ts000f_switch.py index ca98eef0fa..24dbf7b8ae 100644 --- a/zhaquirks/tuya/ts000f_switch.py +++ b/zhaquirks/tuya/ts000f_switch.py @@ -97,3 +97,95 @@ class Tuya_1G_Wall_Switch_Metering(EnchantedDevice): }, }, } + + +class Tuya_2G_Wall_Switch_Metering(EnchantedDevice): + """Tuya 2 gang wall switch with metering and restore power state support.""" + + signature = { + MODEL: "TS000F", + ENDPOINTS: { + # SizePrefixedSimpleDescriptor(endpoint=242, profile=41440, device_type=97, device_version=0, input_clusters=[], output_clusters=[33]) + # input_clusters=["0x0000","0x0004","0x0005","0x0006","0xe000","0xe001"] + # output_clusters=["0x000a","0x0019"]> + 1: { + PROFILE_ID: zha.PROFILE_ID, + DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT, + INPUT_CLUSTERS: [ + Basic.cluster_id, + Groups.cluster_id, + Scenes.cluster_id, + OnOff.cluster_id, + TuyaZBE000Cluster.cluster_id, + TuyaZBExternalSwitchTypeCluster.cluster_id + ], + OUTPUT_CLUSTERS: [ + Time.cluster_id, + Ota.cluster_id + ], + }, + # SizePrefixedSimpleDescriptor(endpoint=242, profile=41440, device_type=97, device_version=0, input_clusters=[], output_clusters=[33]) + # input_clusters=["0x0004","0x0005","0x0006","0xe001"] + # output_clusters=[]> + 2: { + PROFILE_ID: zha.PROFILE_ID, + DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT, + INPUT_CLUSTERS: [ + Groups.cluster_id, + Scenes.cluster_id, + OnOff.cluster_id, + TuyaZBExternalSwitchTypeCluster.cluster_id + ], + OUTPUT_CLUSTERS: [], + }, + # + 242: { + PROFILE_ID: zgp.PROFILE_ID, + DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC, + INPUT_CLUSTERS: [], + OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id], + }, + }, + } + replacement = { + ENDPOINTS: { + 1: { + PROFILE_ID: zha.PROFILE_ID, + DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT, + INPUT_CLUSTERS: [ + Basic.cluster_id, + Groups.cluster_id, + Scenes.cluster_id, + OnOff.cluster_id, + TuyaZBE000Cluster, + TuyaZBExternalSwitchTypeCluster + ], + OUTPUT_CLUSTERS: [ + Time.cluster_id, + Ota.cluster_id + ], + }, + # SizePrefixedSimpleDescriptor(endpoint=242, profile=41440, device_type=97, device_version=0, input_clusters=[], output_clusters=[33]) + # input_clusters=["0x0004","0x0005","0x0006","0xe001"] + # output_clusters=["0x000a","0x0019"]> + 2: { + PROFILE_ID: zha.PROFILE_ID, + DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT, + INPUT_CLUSTERS: [ + Groups.cluster_id, + Scenes.cluster_id, + OnOff.cluster_id, + TuyaZBExternalSwitchTypeCluster + ], + OUTPUT_CLUSTERS: [], + }, + 242: { + PROFILE_ID: zgp.PROFILE_ID, + DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC, + INPUT_CLUSTERS: [], + OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id], + }, + }, + } From 0af64301b516d561a9fb19fb447c8076d3e3f105 Mon Sep 17 00:00:00 2001 From: peper0 Date: Wed, 17 Apr 2024 02:33:56 +0200 Subject: [PATCH 2/8] Update ts000f_switch.py --- zhaquirks/tuya/ts000f_switch.py | 1 + 1 file changed, 1 insertion(+) diff --git a/zhaquirks/tuya/ts000f_switch.py b/zhaquirks/tuya/ts000f_switch.py index 24dbf7b8ae..140aa11c66 100644 --- a/zhaquirks/tuya/ts000f_switch.py +++ b/zhaquirks/tuya/ts000f_switch.py @@ -28,6 +28,7 @@ TuyaZBElectricalMeasurement, TuyaZBMeteringCluster, TuyaZBOnOffAttributeCluster, + TuyaZBExternalSwitchTypeCluster, ) From af69eba25b0cb954bfe50f63a695c71e2199edec Mon Sep 17 00:00:00 2001 From: peper0 Date: Sun, 2 Jun 2024 09:07:31 +0200 Subject: [PATCH 3/8] Update zhaquirks/tuya/ts000f_switch.py Co-authored-by: TheJulianJES --- zhaquirks/tuya/ts000f_switch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zhaquirks/tuya/ts000f_switch.py b/zhaquirks/tuya/ts000f_switch.py index 140aa11c66..ad2dca3cb7 100644 --- a/zhaquirks/tuya/ts000f_switch.py +++ b/zhaquirks/tuya/ts000f_switch.py @@ -177,7 +177,7 @@ class Tuya_2G_Wall_Switch_Metering(EnchantedDevice): INPUT_CLUSTERS: [ Groups.cluster_id, Scenes.cluster_id, - OnOff.cluster_id, + TuyaZBOnOffAttributeCluster, TuyaZBExternalSwitchTypeCluster ], OUTPUT_CLUSTERS: [], From 8ee2428cd9cac8646daef9f88246157e0aaa86ea Mon Sep 17 00:00:00 2001 From: peper0 Date: Sun, 2 Jun 2024 09:07:36 +0200 Subject: [PATCH 4/8] Update zhaquirks/tuya/ts000f_switch.py Co-authored-by: TheJulianJES --- zhaquirks/tuya/ts000f_switch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zhaquirks/tuya/ts000f_switch.py b/zhaquirks/tuya/ts000f_switch.py index ad2dca3cb7..abe4410ca5 100644 --- a/zhaquirks/tuya/ts000f_switch.py +++ b/zhaquirks/tuya/ts000f_switch.py @@ -159,7 +159,7 @@ class Tuya_2G_Wall_Switch_Metering(EnchantedDevice): Basic.cluster_id, Groups.cluster_id, Scenes.cluster_id, - OnOff.cluster_id, + TuyaZBOnOffAttributeCluster, TuyaZBE000Cluster, TuyaZBExternalSwitchTypeCluster ], From b3b102cb3d4e842596242973f4da2ba7612dae47 Mon Sep 17 00:00:00 2001 From: peper0 Date: Sun, 2 Jun 2024 09:10:54 +0200 Subject: [PATCH 5/8] Update ts000f_switch.py --- zhaquirks/tuya/ts000f_switch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zhaquirks/tuya/ts000f_switch.py b/zhaquirks/tuya/ts000f_switch.py index abe4410ca5..e59a5def72 100644 --- a/zhaquirks/tuya/ts000f_switch.py +++ b/zhaquirks/tuya/ts000f_switch.py @@ -26,9 +26,9 @@ TuyaZB1888Cluster, TuyaZBE000Cluster, TuyaZBElectricalMeasurement, + TuyaZBExternalSwitchTypeCluster, TuyaZBMeteringCluster, TuyaZBOnOffAttributeCluster, - TuyaZBExternalSwitchTypeCluster, ) From 749b7d032c040222102927619324bb1e8223ae87 Mon Sep 17 00:00:00 2001 From: TheJulianJES Date: Mon, 26 Aug 2024 21:44:44 +0200 Subject: [PATCH 6/8] Remove cluster comments Most of these had endpoint=242, so seem to be incorrect. They're not important anyway, so removing them. --- zhaquirks/tuya/ts000f_switch.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/zhaquirks/tuya/ts000f_switch.py b/zhaquirks/tuya/ts000f_switch.py index e59a5def72..01a9dae67e 100644 --- a/zhaquirks/tuya/ts000f_switch.py +++ b/zhaquirks/tuya/ts000f_switch.py @@ -106,9 +106,6 @@ class Tuya_2G_Wall_Switch_Metering(EnchantedDevice): signature = { MODEL: "TS000F", ENDPOINTS: { - # SizePrefixedSimpleDescriptor(endpoint=242, profile=41440, device_type=97, device_version=0, input_clusters=[], output_clusters=[33]) - # input_clusters=["0x0000","0x0004","0x0005","0x0006","0xe000","0xe001"] - # output_clusters=["0x000a","0x0019"]> 1: { PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT, @@ -125,9 +122,6 @@ class Tuya_2G_Wall_Switch_Metering(EnchantedDevice): Ota.cluster_id ], }, - # SizePrefixedSimpleDescriptor(endpoint=242, profile=41440, device_type=97, device_version=0, input_clusters=[], output_clusters=[33]) - # input_clusters=["0x0004","0x0005","0x0006","0xe001"] - # output_clusters=[]> 2: { PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT, @@ -139,9 +133,6 @@ class Tuya_2G_Wall_Switch_Metering(EnchantedDevice): ], OUTPUT_CLUSTERS: [], }, - # 242: { PROFILE_ID: zgp.PROFILE_ID, DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC, @@ -168,9 +159,6 @@ class Tuya_2G_Wall_Switch_Metering(EnchantedDevice): Ota.cluster_id ], }, - # SizePrefixedSimpleDescriptor(endpoint=242, profile=41440, device_type=97, device_version=0, input_clusters=[], output_clusters=[33]) - # input_clusters=["0x0004","0x0005","0x0006","0xe001"] - # output_clusters=["0x000a","0x0019"]> 2: { PROFILE_ID: zha.PROFILE_ID, DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT, From 3d086dcd7847a5c83629ca91f20d8ce5451b0cb5 Mon Sep 17 00:00:00 2001 From: TheJulianJES Date: Mon, 26 Aug 2024 21:48:55 +0200 Subject: [PATCH 7/8] Apply changes for pre-commit --- zhaquirks/tuya/ts000f_switch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zhaquirks/tuya/ts000f_switch.py b/zhaquirks/tuya/ts000f_switch.py index 01a9dae67e..69e373cd03 100644 --- a/zhaquirks/tuya/ts000f_switch.py +++ b/zhaquirks/tuya/ts000f_switch.py @@ -152,11 +152,11 @@ class Tuya_2G_Wall_Switch_Metering(EnchantedDevice): Scenes.cluster_id, TuyaZBOnOffAttributeCluster, TuyaZBE000Cluster, - TuyaZBExternalSwitchTypeCluster + TuyaZBExternalSwitchTypeCluster, ], OUTPUT_CLUSTERS: [ Time.cluster_id, - Ota.cluster_id + Ota.cluster_id, ], }, 2: { @@ -166,7 +166,7 @@ class Tuya_2G_Wall_Switch_Metering(EnchantedDevice): Groups.cluster_id, Scenes.cluster_id, TuyaZBOnOffAttributeCluster, - TuyaZBExternalSwitchTypeCluster + TuyaZBExternalSwitchTypeCluster, ], OUTPUT_CLUSTERS: [], }, From d1bec697402c40e4bde18b482742ea729ac79fc4 Mon Sep 17 00:00:00 2001 From: TheJulianJES Date: Mon, 26 Aug 2024 21:56:12 +0200 Subject: [PATCH 8/8] Apply changes for pre-commit --- zhaquirks/tuya/ts000f_switch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zhaquirks/tuya/ts000f_switch.py b/zhaquirks/tuya/ts000f_switch.py index 69e373cd03..62136852d0 100644 --- a/zhaquirks/tuya/ts000f_switch.py +++ b/zhaquirks/tuya/ts000f_switch.py @@ -115,11 +115,11 @@ class Tuya_2G_Wall_Switch_Metering(EnchantedDevice): Scenes.cluster_id, OnOff.cluster_id, TuyaZBE000Cluster.cluster_id, - TuyaZBExternalSwitchTypeCluster.cluster_id + TuyaZBExternalSwitchTypeCluster.cluster_id, ], OUTPUT_CLUSTERS: [ Time.cluster_id, - Ota.cluster_id + Ota.cluster_id, ], }, 2: { @@ -129,7 +129,7 @@ class Tuya_2G_Wall_Switch_Metering(EnchantedDevice): Groups.cluster_id, Scenes.cluster_id, OnOff.cluster_id, - TuyaZBExternalSwitchTypeCluster.cluster_id + TuyaZBExternalSwitchTypeCluster.cluster_id, ], OUTPUT_CLUSTERS: [], },