From c563a602dba77353691360c317cf1a5d44e40b19 Mon Sep 17 00:00:00 2001 From: TheJulianJES Date: Mon, 25 Sep 2023 01:37:17 +0200 Subject: [PATCH] Add Tuya TS011F plug variant, add Tuya `0x1888` cluster class (#2592) * Add Tuya TS011F plug variant * Use correct cluster: `TuyaZBE000Cluster` * Add `TuyaZB1888Cluster` cluster class due to it being outside manufacturer range * Use `TuyaZB1888Cluster` for new Tuya plug quirk * Change `ep_attribute` of Tuya clusters --- zhaquirks/tuya/__init__.py | 14 ++++++- zhaquirks/tuya/ts011f_plug.py | 73 +++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/zhaquirks/tuya/__init__.py b/zhaquirks/tuya/__init__.py index c41e3e9f85..8ade6c6e6d 100644 --- a/zhaquirks/tuya/__init__.py +++ b/zhaquirks/tuya/__init__.py @@ -30,6 +30,7 @@ TUYA_CLUSTER_ID = 0xEF00 TUYA_CLUSTER_E000_ID = 0xE000 TUYA_CLUSTER_E001_ID = 0xE001 +TUYA_CLUSTER_1888_ID = 0x1888 # --------------------------------------------------------- # Tuya Cluster Commands # --------------------------------------------------------- @@ -1105,9 +1106,9 @@ class TuyaZBElectricalMeasurement(CustomCluster, ElectricalMeasurement): class TuyaZBE000Cluster(CustomCluster): """Tuya manufacturer specific cluster 57344.""" - name = "Tuya Manufacturer Specific" + name = "Tuya Manufacturer Specific 0" cluster_id = TUYA_CLUSTER_E000_ID - ep_attribute = "tuya_is_pita_0" + ep_attribute = "tuya_manufacturer_specific_57344" # Tuya Zigbee Cluster 0xE001 Implementation @@ -1128,6 +1129,15 @@ class TuyaZBExternalSwitchTypeCluster(CustomCluster): attributes = {0xD030: ("external_switch_type", ExternalSwitchType)} +# Tuya Zigbee Cluster 0x1888 Implementation +class TuyaZB1888Cluster(CustomCluster): + """Tuya manufacturer specific cluster 6280.""" + + name = "Tuya Manufacturer Specific 1" + cluster_id = TUYA_CLUSTER_1888_ID + ep_attribute = "tuya_manufacturer_specific_6280" + + # Tuya Window Cover Implementation class TuyaManufacturerWindowCover(TuyaManufCluster): """Manufacturer Specific Cluster for cover device.""" diff --git a/zhaquirks/tuya/ts011f_plug.py b/zhaquirks/tuya/ts011f_plug.py index dbf501b650..1f540e167e 100644 --- a/zhaquirks/tuya/ts011f_plug.py +++ b/zhaquirks/tuya/ts011f_plug.py @@ -13,6 +13,7 @@ Time, ) from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement +from zigpy.zcl.clusters.lightlink import LightLink from zigpy.zcl.clusters.measurement import TemperatureMeasurement from zigpy.zcl.clusters.smartenergy import Metering @@ -27,6 +28,7 @@ ) from zhaquirks.tuya import ( TuyaNewManufCluster, + TuyaZB1888Cluster, TuyaZBE000Cluster, TuyaZBElectricalMeasurement, TuyaZBExternalSwitchTypeCluster, @@ -1074,6 +1076,77 @@ class Plug_v2(EnchantedDevice): } +class Plug_v3(EnchantedDevice): + """Tuya TS011F plug. One plug is _Tz3000_0Zfrhq4I.""" + + signature = { + MODEL: "TS011F", + ENDPOINTS: { + 1: { + PROFILE_ID: zha.PROFILE_ID, + DEVICE_TYPE: zha.DeviceType.SMART_PLUG, + INPUT_CLUSTERS: [ + Basic.cluster_id, + Identify.cluster_id, + Groups.cluster_id, + Scenes.cluster_id, + OnOff.cluster_id, + Time.cluster_id, + Metering.cluster_id, + ElectricalMeasurement.cluster_id, + LightLink.cluster_id, + TuyaZB1888Cluster.cluster_id, + TuyaZBE000Cluster.cluster_id, + ], + OUTPUT_CLUSTERS: [ + Ota.cluster_id, + ], + }, + 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.SMART_PLUG, + INPUT_CLUSTERS: [ + Basic.cluster_id, + Identify.cluster_id, + Groups.cluster_id, + Scenes.cluster_id, + TuyaZBOnOffAttributeCluster, + Time.cluster_id, + TuyaZBMeteringClusterWithUnit, + TuyaZBElectricalMeasurement, + LightLink.cluster_id, + TuyaZB1888Cluster, + TuyaZBE000Cluster, + ], + OUTPUT_CLUSTERS: [ + Ota.cluster_id, + ], + }, + 242: { + PROFILE_ID: zgp.PROFILE_ID, + DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC, + INPUT_CLUSTERS: [], + OUTPUT_CLUSTERS: [ + GreenPowerProxy.cluster_id, + ], + }, + }, + } + + class Plug_2AC_var03(CustomDevice): """Tuya 2 socket wall outlet with child lock and power-restore state support."""