|
1 | 1 | """Smoke Sensor."""
|
2 | 2 |
|
| 3 | +from zigpy.quirks.v2 import EntityType, QuirkBuilder |
| 4 | +from zigpy.quirks.v2.homeassistant.binary_sensor import BinarySensorDeviceClass |
| 5 | +import zigpy.types as t |
| 6 | +from zigpy.zcl.clusters.general import OnOff, Time |
| 7 | +from zigpy.zcl.clusters.lightlink import LightLink |
| 8 | +from zigpy.zcl.clusters.security import IasZone |
| 9 | +from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef |
| 10 | + |
| 11 | +from zhaquirks import LocalDataCluster |
| 12 | +from zhaquirks.tuya import TuyaManufClusterAttributes |
3 | 13 | from zhaquirks.tuya.builder import TuyaPowerConfigurationCluster2AAA, TuyaQuirkBuilder
|
4 | 14 |
|
| 15 | + |
| 16 | +class TuyaIasZone(LocalDataCluster, IasZone): |
| 17 | + """IAS Zone.""" |
| 18 | + |
| 19 | + _CONSTANT_ATTRIBUTES = { |
| 20 | + IasZone.AttributeDefs.zone_type.id: IasZone.ZoneType.Fire_Sensor |
| 21 | + } |
| 22 | + |
| 23 | + |
| 24 | +class TuyaSmokeDetectorCluster(TuyaManufClusterAttributes): |
| 25 | + """Manufacturer Specific Cluster of the TS0205 smoke detector.""" |
| 26 | + |
| 27 | + class AttributeDefs(BaseAttributeDefs): |
| 28 | + """Attribute definitions.""" |
| 29 | + |
| 30 | + smoke_detected = ZCLAttributeDef( |
| 31 | + id=0x0401, # [0]/[1] [Detected]/[Clear] |
| 32 | + type=t.uint8_t, |
| 33 | + is_manufacturer_specific=True, |
| 34 | + ) |
| 35 | + |
| 36 | + def _update_attribute(self, attrid, value): |
| 37 | + super()._update_attribute(attrid, value) |
| 38 | + if attrid == self.AttributeDefs.smoke_detected.id: |
| 39 | + self.endpoint.ias_zone.update_attribute( |
| 40 | + IasZone.AttributeDefs.zone_status.id, |
| 41 | + IasZone.ZoneStatus.Alarm_1 if value == 0 else 0, |
| 42 | + ) |
| 43 | + |
| 44 | + |
| 45 | +( |
| 46 | + QuirkBuilder("_TZ3210_up3pngle", "TS0205") |
| 47 | + .removes(LightLink.cluster_id) |
| 48 | + .removes(OnOff.cluster_id) |
| 49 | + .removes(Time.cluster_id) |
| 50 | + .replaces(TuyaIasZone) |
| 51 | + .replaces(TuyaSmokeDetectorCluster) |
| 52 | + .add_to_registry() |
| 53 | +) |
| 54 | + |
5 | 55 | (
|
6 | 56 | TuyaQuirkBuilder("_TZE200_aycxwiau", "TS0601")
|
7 | 57 | .applies_to("_TZE200_dq1mfjug", "TS0601")
|
8 | 58 | .applies_to("_TZE200_m9skfctm", "TS0601")
|
9 |
| - .applies_to("_TZE200_ntcy3xu1", "TS0601") |
10 | 59 | .applies_to("_TZE200_rccxox8p", "TS0601")
|
11 | 60 | .applies_to("_TZE284_rccxox8p", "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()
|
19 | 67 | )
|
20 | 68 |
|
21 | 69 | (
|
22 | 70 | TuyaQuirkBuilder("_TZE204_ntcy3xu1", "TS0601")
|
| 71 | + .applies_to("_TZE200_ntcy3xu1", "TS0601") |
23 | 72 | .tuya_smoke(dp_id=1)
|
| 73 | + .tuya_binary_sensor( |
| 74 | + dp_id=4, |
| 75 | + attribute_name="tamper", |
| 76 | + device_class=BinarySensorDeviceClass.TAMPER, |
| 77 | + entity_type=EntityType.DIAGNOSTIC, |
| 78 | + fallback_name="Tamper", |
| 79 | + ) |
24 | 80 | .tuya_dp(
|
25 | 81 | dp_id=14,
|
26 | 82 | ep_attribute=TuyaPowerConfigurationCluster2AAA.ep_attribute,
|
|
0 commit comments