Skip to content

Commit

Permalink
Add Tuya TS011F plug variant, add Tuya 0x1888 cluster class (#2592)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
TheJulianJES authored Sep 24, 2023
1 parent a09bb0d commit bbee055
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 2 deletions.
14 changes: 12 additions & 2 deletions zhaquirks/tuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ---------------------------------------------------------
Expand Down Expand Up @@ -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
Expand All @@ -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."""
Expand Down
73 changes: 73 additions & 0 deletions zhaquirks/tuya/ts011f_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -27,6 +28,7 @@
)
from zhaquirks.tuya import (
TuyaNewManufCluster,
TuyaZB1888Cluster,
TuyaZBE000Cluster,
TuyaZBElectricalMeasurement,
TuyaZBExternalSwitchTypeCluster,
Expand Down Expand Up @@ -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."""

Expand Down

0 comments on commit bbee055

Please sign in to comment.