Skip to content

Commit

Permalink
Add quirk for CentraLite 3156105 thermostat
Browse files Browse the repository at this point in the history
  • Loading branch information
George Macon committed Jan 12, 2025
1 parent d80730f commit 39fcf85
Showing 1 changed file with 127 additions and 0 deletions.
127 changes: 127 additions & 0 deletions zhaquirks/centralite/cl_3156105.py
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

Check warning on line 49 in zhaquirks/centralite/cl_3156105.py

View check run for this annotation

Codecov / codecov/patch

zhaquirks/centralite/cl_3156105.py#L47-L49

Added lines #L47 - L49 were not covered by tests

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 &= ~(

Check warning on line 56 in zhaquirks/centralite/cl_3156105.py

View check run for this annotation

Codecov / codecov/patch

zhaquirks/centralite/cl_3156105.py#L52-L56

Added lines #L52 - L56 were not covered by tests
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 & (

Check warning on line 65 in zhaquirks/centralite/cl_3156105.py

View check run for this annotation

Codecov / codecov/patch

zhaquirks/centralite/cl_3156105.py#L62-L65

Added lines #L62 - L65 were not covered by tests
RunningState.Heat_State_On | RunningState.Heat_2nd_Stage_On
):
value = RunningMode.Heat
elif self.raw_running_state & (

Check warning on line 69 in zhaquirks/centralite/cl_3156105.py

View check run for this annotation

Codecov / codecov/patch

zhaquirks/centralite/cl_3156105.py#L68-L69

Added lines #L68 - L69 were not covered by tests
RunningState.Cool_State_On | RunningState.Cool_2nd_Stage_On
):
value = RunningMode.Cool

Check warning on line 72 in zhaquirks/centralite/cl_3156105.py

View check run for this annotation

Codecov / codecov/patch

zhaquirks/centralite/cl_3156105.py#L72

Added line #L72 was not covered by tests
else:
value = RunningMode.Off

Check warning on line 74 in zhaquirks/centralite/cl_3156105.py

View check run for this annotation

Codecov / codecov/patch

zhaquirks/centralite/cl_3156105.py#L74

Added line #L74 was not covered by tests

super()._update_attribute(attrid, value)

Check warning on line 76 in zhaquirks/centralite/cl_3156105.py

View check run for this annotation

Codecov / codecov/patch

zhaquirks/centralite/cl_3156105.py#L76

Added line #L76 was not covered by tests


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,
],
}
}
}

0 comments on commit 39fcf85

Please sign in to comment.