Skip to content

Commit d6c8ee2

Browse files
committed
Migrate quirks, pass 26
1 parent 8a99192 commit d6c8ee2

File tree

1 file changed

+13
-112
lines changed

1 file changed

+13
-112
lines changed

zhaquirks/waxman/leaksmart.py

Lines changed: 13 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,16 @@
33
# pylint: disable=W0102
44
from typing import Any, Optional, Union
55

6-
from zigpy.profiles import zha
7-
from zigpy.quirks import CustomCluster, CustomDevice
6+
from zigpy.quirks import CustomCluster
7+
from zigpy.quirks.v2 import CustomDeviceV2, QuirkBuilder
88
import zigpy.types as t
99
from zigpy.zcl import foundation
10-
from zigpy.zcl.clusters.general import (
11-
Basic,
12-
Identify,
13-
Ota,
14-
PollControl,
15-
PowerConfiguration,
16-
)
1710
from zigpy.zcl.clusters.homeautomation import ApplianceEventAlerts
18-
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
1911
from zigpy.zcl.clusters.security import IasZone
2012
from zigpy.zcl.foundation import BaseCommandDefs
2113

2214
from zhaquirks import Bus, LocalDataCluster
23-
from zhaquirks.const import (
24-
CLUSTER_COMMAND,
25-
DEVICE_TYPE,
26-
ENDPOINTS,
27-
INPUT_CLUSTERS,
28-
MODELS_INFO,
29-
OUTPUT_CLUSTERS,
30-
PROFILE_ID,
31-
)
15+
from zhaquirks.const import CLUSTER_COMMAND
3216
from zhaquirks.waxman import WAXMAN
3317

3418
MANUFACTURER_SPECIFIC_CLUSTER_ID = 0xFC02 # decimal = 64514
@@ -93,103 +77,20 @@ def handle_cluster_request(
9377
self.endpoint.device.ias_bus.listener_event("update_state", state)
9478

9579

96-
class WAXMANleakSMARTv2(CustomDevice):
97-
"""Custom device representing WAXMAN leakSMART v2."""
80+
class WAXMANLeakSmartCustomDevice(CustomDeviceV2):
81+
"""Custom device for WAXMAN leakSMART with Bus support."""
9882

9983
def __init__(self, *args, **kwargs):
10084
"""Init."""
10185
self.ias_bus = Bus()
10286
super().__init__(*args, **kwargs)
10387

104-
signature = {
105-
# <SimpleDescriptor endpoint=1 profile=260 device_type=770
106-
# device_version=0
107-
# input_clusters=[0, 1, 3, 32, 1026, 2818, 64514]
108-
# output_clusters=[3, 25]>
109-
MODELS_INFO: [(WAXMAN, "leakSMART Water Sensor V2")],
110-
ENDPOINTS: {
111-
1: {
112-
PROFILE_ID: zha.PROFILE_ID,
113-
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
114-
INPUT_CLUSTERS: [
115-
Basic.cluster_id,
116-
PowerConfiguration.cluster_id,
117-
Identify.cluster_id,
118-
PollControl.cluster_id,
119-
TemperatureMeasurement.cluster_id,
120-
ApplianceEventAlerts.cluster_id,
121-
MANUFACTURER_SPECIFIC_CLUSTER_ID,
122-
],
123-
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
124-
}
125-
},
126-
}
127-
128-
replacement = {
129-
ENDPOINTS: {
130-
1: {
131-
PROFILE_ID: zha.PROFILE_ID,
132-
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
133-
INPUT_CLUSTERS: [
134-
Basic.cluster_id,
135-
PowerConfiguration.cluster_id,
136-
Identify.cluster_id,
137-
PollControl.cluster_id,
138-
TemperatureMeasurement.cluster_id,
139-
WAXMANApplianceEventAlerts,
140-
EmulatedIasZone,
141-
],
142-
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
143-
}
144-
}
145-
}
146-
147-
148-
class WAXMANleakSMARTv2NOPOLL(CustomDevice):
149-
"""Custom WAXMAN leakSMART v2 without PollControl cluster."""
150-
151-
def __init__(self, *args, **kwargs):
152-
"""Init."""
153-
self.ias_bus = Bus()
154-
super().__init__(*args, **kwargs)
15588

156-
signature = {
157-
# <SimpleDescriptor endpoint=1 profile=260 device_type=770
158-
# device_version=0
159-
# input_clusters=[0, 1, 3, 1026, 2818, 64514]
160-
# output_clusters=[3, 25]>
161-
MODELS_INFO: [(WAXMAN, "leakSMART Water Sensor V2")],
162-
ENDPOINTS: {
163-
1: {
164-
PROFILE_ID: zha.PROFILE_ID,
165-
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
166-
INPUT_CLUSTERS: [
167-
Basic.cluster_id,
168-
PowerConfiguration.cluster_id,
169-
Identify.cluster_id,
170-
TemperatureMeasurement.cluster_id,
171-
ApplianceEventAlerts.cluster_id,
172-
MANUFACTURER_SPECIFIC_CLUSTER_ID,
173-
],
174-
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
175-
}
176-
},
177-
}
178-
179-
replacement = {
180-
ENDPOINTS: {
181-
1: {
182-
PROFILE_ID: zha.PROFILE_ID,
183-
DEVICE_TYPE: zha.DeviceType.TEMPERATURE_SENSOR,
184-
INPUT_CLUSTERS: [
185-
Basic.cluster_id,
186-
PowerConfiguration.cluster_id,
187-
Identify.cluster_id,
188-
TemperatureMeasurement.cluster_id,
189-
WAXMANApplianceEventAlerts,
190-
EmulatedIasZone,
191-
],
192-
OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id],
193-
}
194-
}
195-
}
89+
(
90+
QuirkBuilder(WAXMAN, "leakSMART Water Sensor V2")
91+
.device_class(WAXMANLeakSmartCustomDevice)
92+
.removes(MANUFACTURER_SPECIFIC_CLUSTER_ID, endpoint_id=1)
93+
.replaces(WAXMANApplianceEventAlerts, endpoint_id=1)
94+
.adds(EmulatedIasZone, endpoint_id=1)
95+
.add_to_registry()
96+
)

0 commit comments

Comments
 (0)