|
1 | 1 | """Smoke Sensor."""
|
2 | 2 |
|
| 3 | +from zigpy.quirks.v2 import QuirkBuilder |
| 4 | +import zigpy.types as t |
| 5 | +from zigpy.zcl.clusters.general import OnOff, Time |
| 6 | +from zigpy.zcl.clusters.lightlink import LightLink |
| 7 | +from zigpy.zcl.clusters.security import IasZone |
| 8 | +from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef |
| 9 | + |
| 10 | +from zhaquirks import LocalDataCluster |
| 11 | +from zhaquirks.tuya import TuyaManufClusterAttributes |
3 | 12 | from zhaquirks.tuya.builder import TuyaPowerConfigurationCluster2AAA, TuyaQuirkBuilder
|
4 | 13 |
|
| 14 | + |
| 15 | +class TuyaIasZone(LocalDataCluster, IasZone): |
| 16 | + """IAS Zone.""" |
| 17 | + |
| 18 | + _CONSTANT_ATTRIBUTES = { |
| 19 | + IasZone.AttributeDefs.zone_type.id: IasZone.ZoneType.Fire_Sensor |
| 20 | + } |
| 21 | + |
| 22 | + |
| 23 | +class TuyaSmokeDetectorCluster(TuyaManufClusterAttributes): |
| 24 | + """Manufacturer Specific Cluster of the TS0205 smoke detector.""" |
| 25 | + |
| 26 | + class AttributeDefs(BaseAttributeDefs): |
| 27 | + """Attribute definitions.""" |
| 28 | + |
| 29 | + smoke_detected = ZCLAttributeDef( |
| 30 | + id=0x0401, # [0]/[1] [Detected]/[Clear] |
| 31 | + type=t.uint8_t, |
| 32 | + is_manufacturer_specific=True, |
| 33 | + ) |
| 34 | + |
| 35 | + def _update_attribute(self, attrid, value): |
| 36 | + super()._update_attribute(attrid, value) |
| 37 | + if attrid == self.AttributeDefs.smoke_detected.id: |
| 38 | + self.endpoint.ias_zone.update_attribute( |
| 39 | + IasZone.AttributeDefs.zone_status.id, |
| 40 | + IasZone.ZoneStatus.Alarm_1 if value == 0 else 0, |
| 41 | + ) |
| 42 | + |
| 43 | + |
| 44 | +( |
| 45 | + QuirkBuilder("_TZ3210_up3pngle", "TS0205") |
| 46 | + .removes(LightLink.cluster_id) |
| 47 | + .removes(OnOff.cluster_id) |
| 48 | + .removes(Time.cluster_id) |
| 49 | + .replaces(TuyaIasZone) |
| 50 | + .replaces(TuyaSmokeDetectorCluster) |
| 51 | + .add_to_registry() |
| 52 | +) |
| 53 | + |
5 | 54 | (
|
6 | 55 | TuyaQuirkBuilder("_TZE200_aycxwiau", "TS0601")
|
7 | 56 | .applies_to("_TZE200_dq1mfjug", "TS0601")
|
|
12 | 61 | .applies_to("_TZE200_vzekyi4c", "TS0601")
|
13 | 62 | .applies_to("_TZE204_vawy74yh", "TS0601")
|
14 | 63 | .applies_to("_TZE284_0zaf1cr8", "TS0601")
|
15 |
| - .applies_to("_TZ3210_up3pngle", "TS0205") |
16 | 64 | .tuya_smoke(dp_id=1)
|
17 | 65 | .skip_configuration()
|
18 | 66 | .add_to_registry()
|
|
0 commit comments