|
| 1 | +"""Module to handle quirks of the Sinopé Technologies switches SP2600ZB and SP2610ZB.""" |
| 2 | + |
| 3 | +import zigpy.profiles.zha as zha_p |
| 4 | +from zigpy.quirks import CustomCluster, CustomDevice |
| 5 | +from zigpy.zcl.clusters.general import Basic, Identify, OnOff, Ota |
| 6 | +from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement |
| 7 | +from zigpy.zcl.clusters.smartenergy import Metering |
| 8 | + |
| 9 | +from zhaquirks.const import ( |
| 10 | + DEVICE_TYPE, |
| 11 | + ENDPOINTS, |
| 12 | + INPUT_CLUSTERS, |
| 13 | + MODELS_INFO, |
| 14 | + OUTPUT_CLUSTERS, |
| 15 | + PROFILE_ID, |
| 16 | +) |
| 17 | +from zhaquirks.sinope import SINOPE |
| 18 | + |
| 19 | +SINOPE_MANUFACTURER_CLUSTER_ID = 0xFF01 |
| 20 | + |
| 21 | + |
| 22 | +class CustomMeteringCluster(CustomCluster, Metering): |
| 23 | + """Custom Metering Cluster.""" |
| 24 | + |
| 25 | + DIVISOR = 0x0302 |
| 26 | + _CONSTANT_ATTRIBUTES = {DIVISOR: 1000} |
| 27 | + |
| 28 | + |
| 29 | +class SinopeTechnologiesSwitch(CustomDevice): |
| 30 | + """SinopeTechnologiesSwitch custom device.""" |
| 31 | + |
| 32 | + signature = { |
| 33 | + # <SimpleDescriptor(endpoint=1, profile=260, |
| 34 | + # device_type=81, device_version=0, |
| 35 | + # input_clusters=[0, 3, 6, 1794, 2820, 65281] |
| 36 | + # output_clusters=[25]> |
| 37 | + MODELS_INFO: [(SINOPE, "SP2600ZB"), (SINOPE, "SP2610ZB")], |
| 38 | + ENDPOINTS: { |
| 39 | + 1: { |
| 40 | + PROFILE_ID: zha_p.PROFILE_ID, |
| 41 | + DEVICE_TYPE: zha_p.DeviceType.SMART_PLUG, |
| 42 | + INPUT_CLUSTERS: [ |
| 43 | + Basic.cluster_id, |
| 44 | + Identify.cluster_id, |
| 45 | + OnOff.cluster_id, |
| 46 | + Metering.cluster_id, |
| 47 | + ElectricalMeasurement.cluster_id, |
| 48 | + SINOPE_MANUFACTURER_CLUSTER_ID, |
| 49 | + ], |
| 50 | + OUTPUT_CLUSTERS: [Ota.cluster_id], |
| 51 | + } |
| 52 | + }, |
| 53 | + } |
| 54 | + |
| 55 | + replacement = { |
| 56 | + ENDPOINTS: { |
| 57 | + 1: { |
| 58 | + INPUT_CLUSTERS: [ |
| 59 | + Basic.cluster_id, |
| 60 | + Identify.cluster_id, |
| 61 | + OnOff.cluster_id, |
| 62 | + CustomMeteringCluster, |
| 63 | + ElectricalMeasurement.cluster_id, |
| 64 | + SINOPE_MANUFACTURER_CLUSTER_ID, |
| 65 | + ], |
| 66 | + OUTPUT_CLUSTERS: [Ota.cluster_id], |
| 67 | + } |
| 68 | + } |
| 69 | + } |
0 commit comments