Skip to content

Commit 115ba1e

Browse files
committed
Manual clean up
1 parent 259e574 commit 115ba1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+262
-338
lines changed

zhaquirks/aduro/adurolightncc.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
TURN_ON,
1919
)
2020

21-
ADUROLIGHT_CLUSTER_ID = 64716
22-
23-
2421
(
2522
QuirkBuilder("ADUROLIGHT", "Adurolight_NCC")
2623
.removes(LevelControl, endpoint_id=1)

zhaquirks/centralite/cl_3130.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class CustomPowerConfigurationCluster(PowerConfigurationCluster):
3030
(
3131
QuirkBuilder(OSRAM, "LIGHTIFY Dimming Switch")
3232
.applies_to(CENTRALITE, "3130")
33-
.removes(TemperatureMeasurement.cluster_id, endpoint_id=1)
33+
.removes(TemperatureMeasurement, endpoint_id=1)
3434
.replaces(CustomPowerConfigurationCluster, endpoint_id=1)
3535
.device_automation_triggers(
3636
{

zhaquirks/centralite/cl_3300S.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from zhaquirks import PowerConfigurationCluster
77
from zhaquirks.centralite import CENTRALITE
88

9-
MANUFACTURER_SPECIFIC_PROFILE_ID = 0xC2DF # decimal = 49887
10-
119
(
1210
QuirkBuilder(CENTRALITE, "3300")
1311
# .applies_to(CENTRALITE, "3300-S") # TODO: this is also defined in `ias.py`!

zhaquirks/centralite/cl_3321S.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
.applies_to(CENTRALITE, "3321")
1414
.replaces(PowerConfigurationCluster, endpoint_id=1)
1515
.replaces(CentraLiteAccelCluster, endpoint_id=1)
16-
.removes(PowerConfiguration.cluster_id, endpoint_id=2)
16+
.removes(PowerConfiguration, endpoint_id=2)
1717
.add_to_registry()
1818
)

zhaquirks/centralite/ias.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from zhaquirks import PowerConfigurationCluster
77

88
(
9-
QuirkBuilder("CentraLite", "3300-S")
9+
QuirkBuilder("CentraLite", "3300-S") # TODO: this is also defined in `cl_3300S.py`!
1010
.applies_to("CentraLite", "3315-G")
1111
.applies_to("CentraLite", "3315-L")
1212
.applies_to("CentraLite", "3315-S")
@@ -15,6 +15,6 @@
1515
.applies_to("CentraLite", "3320-L")
1616
.applies_to("CentraLite", "Contact Sensor-A")
1717
.replaces(PowerConfigurationCluster, endpoint_id=1)
18-
.removes(PowerConfiguration.cluster_id, endpoint_id=2)
18+
.removes(PowerConfiguration, endpoint_id=2)
1919
.add_to_registry()
2020
)

zhaquirks/echostar/bell.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
(
1919
QuirkBuilder(" Echostar", " Bell")
2020
.replaces_endpoint(
21-
18,
22-
device_type=zha.DeviceType.ON_OFF_SWITCH,
23-
)
21+
18, device_type=zha.DeviceType.ON_OFF_SWITCH
22+
) # was DIMMER_SWITCH
2423
.device_automation_triggers(
2524
{
2625
(SHORT_PRESS, BUTTON_1): {

zhaquirks/edpwithus/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1 @@
11
"""EDP WithUs module."""
2-
3-
from zigpy.quirks import CustomCluster
4-
from zigpy.zcl.clusters.smartenergy import Metering
5-
6-
7-
class MeteringCluster(CustomCluster, Metering):
8-
"""EDP WithUs Metering cluster."""
9-
10-
MULTIPLIER = 0x0301
11-
DIVISOR = 0x0302
12-
_CONSTANT_ATTRIBUTES = {MULTIPLIER: 1, DIVISOR: 1000}

zhaquirks/edpwithus/redy_plug.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
"""EDP WithUs SmartPlug Quirk."""
22

33
from zigpy.profiles import zha
4+
from zigpy.quirks import CustomCluster
45
from zigpy.quirks.v2 import QuirkBuilder
6+
from zigpy.zcl.clusters.smartenergy import Metering
7+
8+
9+
class MeteringCluster(CustomCluster, Metering):
10+
"""EDP WithUs Metering cluster."""
11+
12+
MULTIPLIER = 0x0301
13+
DIVISOR = 0x0302
14+
_CONSTANT_ATTRIBUTES = {MULTIPLIER: 1, DIVISOR: 1000}
515

6-
from zhaquirks.edpwithus import MeteringCluster
716

817
(
918
QuirkBuilder("EDP-WITHUS", "Smart Plug")
10-
.replaces_endpoint(85, device_type=zha.DeviceType.ON_OFF_PLUG_IN_UNIT)
19+
.replaces_endpoint(
20+
85, device_type=zha.DeviceType.ON_OFF_PLUG_IN_UNIT
21+
) # was MAIN_POWER_OUTLET
1122
.replaces(MeteringCluster, endpoint_id=85)
1223
.add_to_registry()
1324
)

zhaquirks/elko/__init__.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,78 @@
11
"""Module for Elko quirks implementations."""
2+
3+
from zigpy.quirks import CustomCluster
4+
from zigpy.quirks.v2 import CustomDeviceV2
5+
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
6+
from zigpy.zcl.clusters.hvac import Thermostat, UserInterface
7+
8+
from zhaquirks import Bus, LocalDataCluster
9+
10+
ELKO = "ELKO"
11+
12+
13+
class ElkoThermostatCluster(CustomCluster, Thermostat):
14+
"""Thermostat cluster for Elko Thermostats."""
15+
16+
class AttributeDefs(Thermostat.AttributeDefs):
17+
"""Cluster attributes."""
18+
19+
def __init__(self, *args, **kwargs):
20+
"""Init thermostat cluster."""
21+
super().__init__(*args, **kwargs)
22+
self.endpoint.device.thermostat_bus.add_listener(self)
23+
24+
def heating_active_change(self, value):
25+
"""State update from device."""
26+
if value == 0:
27+
mode = self.RunningMode.Off
28+
state = self.RunningState.Idle
29+
else:
30+
mode = self.RunningMode.Heat
31+
state = self.RunningState.Heat_State_On
32+
33+
self._update_attribute(self.attributes_by_name["running_mode"].id, mode)
34+
self._update_attribute(self.attributes_by_name["running_state"].id, state)
35+
36+
37+
class ElkoUserInterfaceCluster(LocalDataCluster, UserInterface):
38+
"""User interface cluster for Elko Thermostats."""
39+
40+
def __init__(self, *args, **kwargs):
41+
"""Init UI cluster."""
42+
super().__init__(*args, **kwargs)
43+
self.endpoint.device.ui_bus.add_listener(self)
44+
45+
def child_lock_change(self, mode):
46+
"""Enable/disable child lock."""
47+
if mode:
48+
lockout = self.KeypadLockout.Level_1_lockout
49+
else:
50+
lockout = self.KeypadLockout.No_lockout
51+
52+
self._update_attribute(self.attributes_by_name["keypad_lockout"].id, lockout)
53+
54+
55+
class ElkoElectricalMeasurementCluster(LocalDataCluster, ElectricalMeasurement):
56+
"""Electrical measurement cluster for Elko Thermostats."""
57+
58+
ACTIVE_POWER_ID = 0x050B
59+
60+
def __init__(self, *args, **kwargs):
61+
"""Init electrical measurement cluster."""
62+
super().__init__(*args, **kwargs)
63+
self.endpoint.device.power_bus.add_listener(self)
64+
65+
def power_reported(self, value):
66+
"""Report consumption."""
67+
self._update_attribute(self.ACTIVE_POWER_ID, value)
68+
69+
70+
class ElkoThermostat(CustomDeviceV2):
71+
"""Generic Elko Thermostat device."""
72+
73+
def __init__(self, *args, **kwargs):
74+
"""Init device."""
75+
self.thermostat_bus = Bus()
76+
self.ui_bus = Bus()
77+
self.power_bus = Bus()
78+
super().__init__(*args, **kwargs)

zhaquirks/elko/smart_super_thermostat.py

Lines changed: 19 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22

33
from typing import Final
44

5-
from zigpy.quirks import CustomCluster
6-
from zigpy.quirks.v2 import CustomDeviceV2, QuirkBuilder
5+
from zigpy.quirks.v2 import QuirkBuilder
76
import zigpy.types as t
8-
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
9-
from zigpy.zcl.clusters.hvac import Thermostat, UserInterface
7+
from zigpy.zcl.clusters.hvac import Thermostat
108
from zigpy.zcl.foundation import ZCLAttributeDef
119

12-
from zhaquirks import Bus, LocalDataCluster
13-
14-
ELKO = "ELKO"
10+
from zhaquirks.elko import (
11+
ELKO,
12+
ElkoElectricalMeasurementCluster,
13+
ElkoThermostat,
14+
ElkoThermostatCluster,
15+
ElkoUserInterfaceCluster,
16+
)
1517

1618
LOCAL_TEMP = 0x0000
1719
UNKNOWN_1 = 0x0401
@@ -35,74 +37,6 @@
3537
UNKNOWN_9 = 0x0419
3638

3739

38-
class ElkoThermostatCluster(CustomCluster, Thermostat):
39-
"""Thermostat cluster for Elko Thermostats."""
40-
41-
class AttributeDefs(Thermostat.AttributeDefs):
42-
"""Cluster attributes."""
43-
44-
def __init__(self, *args, **kwargs):
45-
"""Init thermostat cluster."""
46-
super().__init__(*args, **kwargs)
47-
self.endpoint.device.thermostat_bus.add_listener(self)
48-
49-
def heating_active_change(self, value):
50-
"""State update from device."""
51-
if value == 0:
52-
mode = self.RunningMode.Off
53-
state = self.RunningState.Idle
54-
else:
55-
mode = self.RunningMode.Heat
56-
state = self.RunningState.Heat_State_On
57-
58-
self._update_attribute(self.attributes_by_name["running_mode"].id, mode)
59-
self._update_attribute(self.attributes_by_name["running_state"].id, state)
60-
61-
62-
class ElkoUserInterfaceCluster(LocalDataCluster, UserInterface):
63-
"""User interface cluster for Elko Thermostats."""
64-
65-
def __init__(self, *args, **kwargs):
66-
"""Init UI cluster."""
67-
super().__init__(*args, **kwargs)
68-
self.endpoint.device.ui_bus.add_listener(self)
69-
70-
def child_lock_change(self, mode):
71-
"""Enable/disable child lock."""
72-
if mode:
73-
lockout = self.KeypadLockout.Level_1_lockout
74-
else:
75-
lockout = self.KeypadLockout.No_lockout
76-
77-
self._update_attribute(self.attributes_by_name["keypad_lockout"].id, lockout)
78-
79-
80-
class ElkoElectricalMeasurementCluster(LocalDataCluster, ElectricalMeasurement):
81-
"""Electrical measurement cluster for Elko Thermostats."""
82-
83-
ACTIVE_POWER_ID = 0x050B
84-
85-
def __init__(self, *args, **kwargs):
86-
"""Init electrical measurement cluster."""
87-
super().__init__(*args, **kwargs)
88-
self.endpoint.device.power_bus.add_listener(self)
89-
90-
def power_reported(self, value):
91-
"""Report consumption."""
92-
self._update_attribute(self.ACTIVE_POWER_ID, value)
93-
94-
95-
class ElkoThermostat(CustomDeviceV2):
96-
"""Generic Elko Thermostat device."""
97-
98-
def __init__(self, *args, **kwargs):
99-
"""Init device."""
100-
self.thermostat_bus = Bus()
101-
self.ui_bus = Bus()
102-
self.power_bus = Bus()
103-
super().__init__(*args, **kwargs)
104-
105-
10640
class ActiveSensor(t.enum8):
10741
"""Working modes of the thermostat."""
10842

@@ -145,6 +79,7 @@ def __init__(self, *args, **kwargs):
14579
"""Init Elko thermostat."""
14680
super().__init__(*args, **kwargs)
14781
self.active_sensor = None
82+
self.endpoint.device.thermostat_bus.add_listener(self)
14883

14984
async def write_attributes(self, attributes, manufacturer=None):
15085
"""Override writes to thermostat attributes."""
@@ -165,9 +100,15 @@ async def write_attributes(self, attributes, manufacturer=None):
165100

166101
def _update_attribute(self, attrid, value):
167102
if attrid == HEATING_ACTIVE:
168-
self.endpoint.device.thermostat_bus.listener_event(
169-
"heating_active_change", value
170-
)
103+
if value == 0:
104+
mode = self.RunningMode.Off
105+
state = self.RunningState.Idle
106+
else:
107+
mode = self.RunningMode.Heat
108+
state = self.RunningState.Heat_State_On
109+
110+
self._update_attribute(self.attributes_by_name["running_mode"].id, mode)
111+
self._update_attribute(self.attributes_by_name["running_state"].id, state)
171112
elif attrid == CHILD_LOCK:
172113
self.endpoint.device.ui_bus.listener_event("child_lock_change", value)
173114
elif attrid == ACTIVE_SENSOR:

0 commit comments

Comments
 (0)