-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add quirk for CentraLite 3156105 thermostat
- Loading branch information
George Macon
committed
Jan 12, 2025
1 parent
d80730f
commit 39fcf85
Showing
1 changed file
with
127 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 |
---|---|---|
@@ -0,0 +1,127 @@ | ||
"""Device handler for CentraLite 3156105.""" | ||
|
||
from typing import Any | ||
|
||
from zigpy.profiles import zha | ||
from zigpy.quirks import CustomCluster, CustomDevice | ||
from zigpy.zcl.clusters.general import ( | ||
Alarms, | ||
Basic, | ||
Groups, | ||
Identify, | ||
Ota, | ||
PowerConfiguration, | ||
Time, | ||
) | ||
from zigpy.zcl.clusters.hvac import ( | ||
Fan, | ||
RunningMode, | ||
RunningState, | ||
Thermostat, | ||
UserInterface, | ||
) | ||
|
||
from zhaquirks.const import ( | ||
DEVICE_TYPE, | ||
ENDPOINTS, | ||
INPUT_CLUSTERS, | ||
MODELS_INFO, | ||
OUTPUT_CLUSTERS, | ||
PROFILE_ID, | ||
) | ||
|
||
|
||
class CustomThermostatCluster(CustomCluster, Thermostat): | ||
"""Custom Thermostat cluster. | ||
The CL 3156105 has the running mode and running state swapped for the | ||
heat/cool bits. | ||
""" | ||
|
||
raw_running_mode: RunningMode | ||
raw_running_state: RunningState | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Set up state.""" | ||
super().__init__(*args, **kwargs) | ||
self.raw_running_mode = RunningMode.Off | ||
self.raw_running_state = RunningState.Idle | ||
|
||
def _update_attribute(self, attrid: int, value: Any) -> None: | ||
if attrid == self.AttributeDefs.running_state.id: | ||
assert isinstance(value, int) | ||
self.raw_running_state = value | ||
if self.raw_running_mode == RunningMode.Off: | ||
value &= ~( | ||
RunningState.Heat_State_On | ||
| RunningState.Cool_State_On | ||
| RunningState.Heat_2nd_Stage_On | ||
| RunningState.Cool_2nd_Stage_On | ||
) | ||
elif attrid == self.AttributeDefs.running_mode.id: | ||
assert isinstance(value, int) | ||
self.raw_running_mode = value | ||
if self.raw_running_state & ( | ||
RunningState.Heat_State_On | RunningState.Heat_2nd_Stage_On | ||
): | ||
value = RunningMode.Heat | ||
elif self.raw_running_state & ( | ||
RunningState.Cool_State_On | RunningState.Cool_2nd_Stage_On | ||
): | ||
value = RunningMode.Cool | ||
else: | ||
value = RunningMode.Off | ||
|
||
super()._update_attribute(attrid, value) | ||
|
||
|
||
class Centralite3156105(CustomDevice): | ||
"""Custom device representing CentraLite 3156105.""" | ||
|
||
signature = { | ||
MODELS_INFO: [("CentraLite Systems", "3156105")], | ||
ENDPOINTS: { | ||
1: { | ||
PROFILE_ID: zha.PROFILE_ID, | ||
DEVICE_TYPE: zha.DeviceType.THERMOSTAT, | ||
INPUT_CLUSTERS: [ | ||
Basic.cluster_id, | ||
PowerConfiguration.cluster_id, | ||
Identify.cluster_id, | ||
Groups.cluster_id, | ||
Alarms.cluster_id, | ||
Thermostat.cluster_id, | ||
Fan.cluster_id, | ||
UserInterface.cluster_id, | ||
], | ||
OUTPUT_CLUSTERS: [ | ||
Time.cluster_id, | ||
Ota.cluster_id, | ||
], | ||
} | ||
}, | ||
} | ||
|
||
replacement = { | ||
ENDPOINTS: { | ||
1: { | ||
PROFILE_ID: zha.PROFILE_ID, | ||
DEVICE_TYPE: zha.DeviceType.THERMOSTAT, | ||
INPUT_CLUSTERS: [ | ||
Basic.cluster_id, | ||
PowerConfiguration.cluster_id, | ||
Identify.cluster_id, | ||
Groups.cluster_id, | ||
Alarms.cluster_id, | ||
CustomThermostatCluster, | ||
Fan.cluster_id, | ||
UserInterface.cluster_id, | ||
], | ||
OUTPUT_CLUSTERS: [ | ||
Time.cluster_id, | ||
Ota.cluster_id, | ||
], | ||
} | ||
} | ||
} |