-
Notifications
You must be signed in to change notification settings - Fork 726
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NodOn: quirk for SIN-4-FP-21 (using v2 interface)
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,58 @@ | ||
"""NODON module for custom device handlers.""" | ||
|
||
from zigpy.quirks import CustomCluster | ||
import zigpy.types as t | ||
from zigpy.zcl.foundation import ( | ||
BaseAttributeDefs, | ||
BaseCommandDefs, | ||
DataTypeId, | ||
Direction, | ||
ZCLAttributeDef, | ||
ZCLCommandDef, | ||
) | ||
|
||
|
||
class NodOnPilotWireMode(t.enum8): | ||
"""Pilot wire mode.""" | ||
|
||
# Codes taken from | ||
# https://github.com/Koenkk/zigbee-herdsman-converters/blob/0f4833340a20db3dae625a61c41d9be0a6f952be/src/converters/fromZigbee.ts#L5285. | ||
|
||
Off = 0x00 | ||
Comfort = 0x01 | ||
Eco = 0x02 | ||
FrostProtection = 0x03 | ||
ComfortMinus1 = 0x04 | ||
ComfortMinus2 = 0x05 | ||
|
||
NODON = "NodOn" | ||
NODON_PILOT_WIRE_CLUSTER_ID = 0xFC00 #64512 | ||
|
||
class NodOnPilotWireCluster(CustomCluster): | ||
"""NodOn manufacturer specific cluster to set Pilot Wire mode.""" | ||
|
||
name: str = "NodOnPilotWireCluster" | ||
cluster_id: t.uint16_t = NODON_PILOT_WIRE_CLUSTER_ID | ||
ep_attribute: str = "nodon_pilot_wire_cluster" | ||
|
||
class AttributeDefs(BaseAttributeDefs): | ||
"""Attribute definitions.""" | ||
|
||
pilot_wire_mode = ZCLAttributeDef( | ||
id=0x0000, | ||
type=NodOnPilotWireMode, | ||
# I got the following error without setting zcl_type explicitly to int: | ||
# Failed to write attribute pilot_wire_mode=<NodOnPilotWireMode.FrostProtection: 3>: <Status.INVALID_DATA_TYPE: 141> | ||
zcl_type=DataTypeId.uint8, | ||
is_manufacturer_specific=True, | ||
) | ||
|
||
class ServerCommandDefs(BaseCommandDefs): | ||
"""Server command definitions.""" | ||
|
||
set_pilot_wire_mode = ZCLCommandDef( | ||
id=0x00, | ||
schema={"mode": NodOnPilotWireMode}, | ||
direction=Direction.Client_to_Server, | ||
is_manufacturer_specific=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""NodOn pilot wire heating module.""" | ||
|
||
from zigpy.quirks.v2 import QuirkBuilder, EntityType | ||
|
||
from zhaquirks.nodon import ( | ||
NodOnPilotWireCluster, | ||
NodOnPilotWireMode, | ||
NODON_PILOT_WIRE_CLUSTER_ID, | ||
NODON | ||
) | ||
|
||
( | ||
QuirkBuilder(NODON, "SIN-4-FP-21") | ||
.replaces(NodOnPilotWireCluster) | ||
.enum( | ||
attribute_name=NodOnPilotWireCluster.AttributeDefs.pilot_wire_mode.name, | ||
enum_class=NodOnPilotWireMode, | ||
cluster_id=NODON_PILOT_WIRE_CLUSTER_ID, | ||
entity_type=EntityType.STANDARD) | ||
.add_to_registry() | ||
) |