|
| 1 | +"""NodOn pilot wire heating module.""" |
| 2 | + |
| 3 | +from zigpy.quirks import CustomCluster |
| 4 | +from zigpy.quirks.v2 import QuirkBuilder |
| 5 | +import zigpy.types as t |
| 6 | +from zigpy.zcl.foundation import BaseAttributeDefs, DataTypeId, ZCLAttributeDef |
| 7 | + |
| 8 | +NODON = "NodOn" |
| 9 | +NODON_MANUFACTURER_ID = 4747 |
| 10 | +NODON_PILOT_WIRE_CLUSTER_ID = 0xFC00 # 64512 |
| 11 | +ADEO = "Adeo" |
| 12 | + |
| 13 | + |
| 14 | +class NodOnPilotWireMode(t.enum8): |
| 15 | + """Pilot wire mode.""" |
| 16 | + |
| 17 | + # Codes taken from |
| 18 | + # https://github.com/Koenkk/zigbee-herdsman-converters/blob/0f4833340a20db3dae625a61c41d9be0a6f952be/src/converters/fromZigbee.ts#L5285. |
| 19 | + |
| 20 | + Off = 0x00 |
| 21 | + Comfort = 0x01 |
| 22 | + Eco = 0x02 |
| 23 | + FrostProtection = 0x03 |
| 24 | + ComfortMinus1 = 0x04 |
| 25 | + ComfortMinus2 = 0x05 |
| 26 | + |
| 27 | + |
| 28 | +class NodOnPilotWireCluster(CustomCluster): |
| 29 | + """NodOn manufacturer specific cluster to set Pilot Wire mode.""" |
| 30 | + |
| 31 | + name: str = "PilotWireCluster" |
| 32 | + cluster_id: t.uint16_t = NODON_PILOT_WIRE_CLUSTER_ID |
| 33 | + ep_attribute: str = "pilot_wire_cluster" |
| 34 | + |
| 35 | + class AttributeDefs(BaseAttributeDefs): |
| 36 | + """Attribute definitions.""" |
| 37 | + |
| 38 | + pilot_wire_mode = ZCLAttributeDef( |
| 39 | + id=0x0000, |
| 40 | + type=NodOnPilotWireMode, |
| 41 | + # need to explicitly set ZCL type |
| 42 | + zcl_type=DataTypeId.uint8, |
| 43 | + is_manufacturer_specific=True, |
| 44 | + ) |
| 45 | + |
| 46 | + |
| 47 | +class AdeoPilotWireCluster(NodOnPilotWireCluster): |
| 48 | + """Adeo manufacturer specific cluster to set Pilot Wire mode.""" |
| 49 | + |
| 50 | + # Adeo SIN-4-FP-21_EQU has a weird setup where it reports 4727 |
| 51 | + # manufacturer_code in node_descriptor(), but requires NodOn's (4747) |
| 52 | + # manufacturer_id to execute commands and get/set attributes. |
| 53 | + manufacturer_id_override: t.uint16_t = NODON_MANUFACTURER_ID |
| 54 | + |
| 55 | + |
| 56 | +nodon = ( |
| 57 | + QuirkBuilder(NODON, "SIN-4-FP-21") |
| 58 | + .replaces(NodOnPilotWireCluster) |
| 59 | +) # fmt: skip |
| 60 | + |
| 61 | +adeo = ( |
| 62 | + nodon.clone(omit_man_model_data=True) |
| 63 | + .applies_to(ADEO, "SIN-4-FP-21_EQU") |
| 64 | + .replaces(AdeoPilotWireCluster) |
| 65 | +) |
| 66 | + |
| 67 | +nodon.add_to_registry() |
| 68 | +adeo.add_to_registry() |
0 commit comments