|
| 1 | +"""Device handler for smartthings moistureV4 sensor.""" |
| 2 | +from zigpy.profiles import zha |
| 3 | +from zigpy.quirks import CustomDevice |
| 4 | +from zigpy.zcl.clusters.general import Basic, BinaryInput, Identify, Ota, PollControl |
| 5 | +from zigpy.zcl.clusters.measurement import TemperatureMeasurement |
| 6 | +from zigpy.zcl.clusters.security import IasZone |
| 7 | + |
| 8 | +from zhaquirks.centralite import PowerConfigurationCluster |
| 9 | + |
| 10 | +from . import SMART_THINGS |
| 11 | +from ..const import ( |
| 12 | + DEVICE_TYPE, |
| 13 | + ENDPOINTS, |
| 14 | + INPUT_CLUSTERS, |
| 15 | + MODELS_INFO, |
| 16 | + OUTPUT_CLUSTERS, |
| 17 | + PROFILE_ID, |
| 18 | +) |
| 19 | + |
| 20 | + |
| 21 | +class CustomIasZone(IasZone): |
| 22 | + """Custom IasZone cluster.""" |
| 23 | + |
| 24 | + MOISTURE_TYPE = 0x002A |
| 25 | + ZONE_TYPE = 0x0001 |
| 26 | + |
| 27 | + def _update_attribute(self, attrid, value): |
| 28 | + if attrid == self.ZONE_TYPE: |
| 29 | + super()._update_attribute(attrid, self.MOISTURE_TYPE) |
| 30 | + else: |
| 31 | + super()._update_attribute(attrid, value) |
| 32 | + |
| 33 | + |
| 34 | +class SmartThingsMoistureV4(CustomDevice): |
| 35 | + """SmartThingsMoistureV4.""" |
| 36 | + |
| 37 | + signature = { |
| 38 | + # <SimpleDescriptor endpoint=1 profile=260 device_type=1026 |
| 39 | + # device_version=0 |
| 40 | + # input_clusters=[0, 1, 3, 15, 1026, 1280, 32] |
| 41 | + # output_clusters=[25]> |
| 42 | + MODELS_INFO: [(SMART_THINGS, "moisturev4")], |
| 43 | + ENDPOINTS: { |
| 44 | + 1: { |
| 45 | + PROFILE_ID: zha.PROFILE_ID, |
| 46 | + DEVICE_TYPE: zha.DeviceType.IAS_ZONE, |
| 47 | + INPUT_CLUSTERS: [ |
| 48 | + Basic.cluster_id, |
| 49 | + PowerConfigurationCluster.cluster_id, |
| 50 | + Identify.cluster_id, |
| 51 | + BinaryInput.cluster_id, |
| 52 | + PollControl.cluster_id, |
| 53 | + TemperatureMeasurement.cluster_id, |
| 54 | + IasZone.cluster_id, |
| 55 | + ], |
| 56 | + OUTPUT_CLUSTERS: [Ota.cluster_id], |
| 57 | + } |
| 58 | + }, |
| 59 | + } |
| 60 | + |
| 61 | + replacement = { |
| 62 | + ENDPOINTS: { |
| 63 | + 1: { |
| 64 | + INPUT_CLUSTERS: [ |
| 65 | + Basic.cluster_id, |
| 66 | + PowerConfigurationCluster, |
| 67 | + Identify.cluster_id, |
| 68 | + BinaryInput.cluster_id, |
| 69 | + PollControl.cluster_id, |
| 70 | + TemperatureMeasurement.cluster_id, |
| 71 | + CustomIasZone, |
| 72 | + ], |
| 73 | + OUTPUT_CLUSTERS: [Ota.cluster_id], |
| 74 | + } |
| 75 | + } |
| 76 | + } |
0 commit comments