Skip to content

Instantly share code, notes, and snippets.

@erkr
Created July 17, 2023 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save erkr/5d4addf1b4c8e18d68d2adb154c6be93 to your computer and use it in GitHub Desktop.
Save erkr/5d4addf1b4c8e18d68d2adb154c6be93 to your computer and use it in GitHub Desktop.
ZHAQuirk for the tuya switch with power monitoring _TZ3000_xkap8wtb model TS000F.
"""tuya TS000F Wall Switches."""
# This quirk scales both the current and summation readout, and it changes the device from a light into a switch
# Note: this quirk is similar to the offical TS000x quirks, except that this device has quite a different signature.
# That includes a unknown cluster ID 0x1888 that I filtered out.
from zigpy.profiles import zgp, zha
from zigpy.zcl.clusters.general import (
Basic,
GreenPowerProxy,
Groups,
Identify,
OnOff,
Ota,
Scenes,
Time,
)
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODEL,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.tuya import (
TuyaZBE000Cluster,
TuyaZBElectricalMeasurement,
TuyaZBExternalSwitchTypeCluster,
TuyaZBMeteringCluster,
TuyaZBOnOffAttributeCluster,
)
from zhaquirks.tuya.mcu import EnchantedDevice
from zigpy.zcl.clusters.lightlink import LightLink
class Tuya_1G_Wall_Switch_Metering(EnchantedDevice):
"""Tuya 1 gang wall switch with metering support."""
signature = {
# MODELS_INFO: [
# ("_TZ3000_xkap8wtb", "TS000F"),
# ],
MODEL: "TS000F",
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=256
# input_clusters=["0x0000","0x0003","0x0004","0x0005","0x0006","0x000a","0x0702","0x0b04","0x1000","0x1888","0xe000"]
# output_clusters=["0x0019"]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
Time.cluster_id,
TuyaZBMeteringCluster.cluster_id,
TuyaZBElectricalMeasurement.cluster_id,
LightLink.cluster_id,
0x1888,
TuyaZBE000Cluster.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
# input_clusters=[]
# output_clusters=["0x0021"]>
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_PLUG_IN_UNIT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaZBOnOffAttributeCluster,
Time.cluster_id,
TuyaZBMeteringCluster,
TuyaZBElectricalMeasurement,
LightLink.cluster_id,
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],
},
},
}
@arsenyspb
Copy link

Please jump to pull/2613

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment