Skip to content

Commit bdee48d

Browse files
authored
Add quirk for Colorock power monitor switch (#3881)
1 parent dd63a95 commit bdee48d

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

zhaquirks/tuya/ts0001_switch.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""Tuya switch device."""
2+
3+
from zigpy.quirks import CustomCluster
4+
from zigpy.quirks.v2 import QuirkBuilder
5+
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
6+
from zigpy.zcl.clusters.smartenergy import Metering
7+
8+
from zhaquirks.tuya import TuyaZBOnOffAttributeCluster
9+
10+
11+
class CustomElectricalMeasurement(ElectricalMeasurement, CustomCluster):
12+
"""Custom electrical measurement cluster."""
13+
14+
_CONSTANT_ATTRIBUTES = {
15+
ElectricalMeasurement.AttributeDefs.ac_current_multiplier.id: 1,
16+
ElectricalMeasurement.AttributeDefs.ac_current_divisor.id: 1000,
17+
}
18+
19+
20+
class CustomMetering(Metering, CustomCluster):
21+
"""Custom metering cluster."""
22+
23+
KILOWATT_HOURS = 0x0
24+
ELECTRIC_METERING = 0x0
25+
26+
_CONSTANT_ATTRIBUTES = {
27+
Metering.AttributeDefs.unit_of_measure.id: KILOWATT_HOURS,
28+
Metering.AttributeDefs.metering_device_type.id: ELECTRIC_METERING,
29+
Metering.AttributeDefs.multiplier.id: 1,
30+
Metering.AttributeDefs.divisor.id: 100,
31+
}
32+
33+
34+
(
35+
QuirkBuilder("_TZ3000_xkap8wtb", "TS0001")
36+
.applies_to("_TZ3000_qnejhcsu", "TS0001")
37+
.applies_to("_TZ3000_x3ewpzyr", "TS0001")
38+
.applies_to("_TZ3000_mkhkxx1p", "TS0001")
39+
.applies_to("_TZ3000_tgddllx4", "TS0001")
40+
.applies_to("_TZ3000_kqvb5akv", "TS0001")
41+
.applies_to("_TZ3000_g92baclx", "TS0001")
42+
.applies_to("_TZ3000_qlai3277", "TS0001")
43+
.applies_to("_TZ3000_qaabwu5c", "TS0001")
44+
.applies_to("_TZ3000_ikuxinvo", "TS0001")
45+
.applies_to("_TZ3000_hzlsaltw", "TS0001")
46+
.applies_to("_TZ3000_jsfzkftc", "TS0001")
47+
.replaces(CustomMetering)
48+
.replaces(CustomElectricalMeasurement)
49+
.replaces(TuyaZBOnOffAttributeCluster)
50+
.add_to_registry()
51+
)

0 commit comments

Comments
 (0)