Skip to content

Commit 8a99192

Browse files
committed
Migrate quirks, pass 25
1 parent c45a4ad commit 8a99192

File tree

8 files changed

+150
-629
lines changed

8 files changed

+150
-629
lines changed

zhaquirks/elko/smart_super_thermostat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
from typing import Final
44

5-
from zigpy.quirks import CustomCluster, CustomDevice
6-
from zigpy.quirks.v2 import QuirkBuilder
5+
from zigpy.quirks import CustomCluster
6+
from zigpy.quirks.v2 import CustomDeviceV2, QuirkBuilder
77
import zigpy.types as t
88
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
99
from zigpy.zcl.clusters.hvac import Thermostat, UserInterface
@@ -92,7 +92,7 @@ def power_reported(self, value):
9292
self._update_attribute(self.ACTIVE_POWER_ID, value)
9393

9494

95-
class ElkoThermostat(CustomDevice):
95+
class ElkoThermostat(CustomDeviceV2):
9696
"""Generic Elko Thermostat device."""
9797

9898
def __init__(self, *args, **kwargs):
Lines changed: 22 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,7 @@
11
"""Device handler for Insta NEXENTRO Pushbutton Interface."""
22

3-
from zigpy.profiles import zgp, zha
4-
from zigpy.quirks import CustomDevice
5-
from zigpy.zcl.clusters.closures import WindowCovering
6-
from zigpy.zcl.clusters.general import (
7-
Basic,
8-
GreenPowerProxy,
9-
Groups,
10-
Identify,
11-
LevelControl,
12-
OnOff,
13-
Ota,
14-
Scenes,
15-
)
16-
from zigpy.zcl.clusters.lighting import Color
3+
from zigpy.quirks.v2 import QuirkBuilder
174

18-
from zhaquirks import (
19-
DEVICE_TYPE,
20-
ENDPOINTS,
21-
INPUT_CLUSTERS,
22-
MODELS_INFO,
23-
OUTPUT_CLUSTERS,
24-
PROFILE_ID,
25-
)
265
from zhaquirks.const import (
276
ALT_SHORT_PRESS,
287
BUTTON,
@@ -51,157 +30,25 @@
5130
COMMAND_RECALL = "recall"
5231

5332

54-
class InstaNexentroPushbuttonInterface(CustomDevice):
55-
"""Insta NEXENTRO Pushbutton Interface device."""
56-
57-
signature = {
58-
MODELS_INFO: [(INSTA, "NEXENTRO Pushbutton Interface")],
59-
ENDPOINTS: {
60-
# <SimpleDescriptor endpoint=4 profile=260 device_type=261
61-
# device_version=1
62-
# input_clusters=[0, 3]
63-
# output_clusters=[3, 4, 5, 6, 8, 25, 768]>
64-
4: {
65-
PROFILE_ID: zha.PROFILE_ID,
66-
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
67-
INPUT_CLUSTERS: [
68-
Basic.cluster_id,
69-
Identify.cluster_id,
70-
],
71-
OUTPUT_CLUSTERS: [
72-
Identify.cluster_id,
73-
Groups.cluster_id,
74-
Scenes.cluster_id,
75-
OnOff.cluster_id,
76-
LevelControl.cluster_id,
77-
Ota.cluster_id,
78-
Color.cluster_id,
79-
],
80-
},
81-
# <SimpleDescriptor endpoint=5 profile=260 device_type=261
82-
# device_version=1
83-
# input_clusters=[0, 3]
84-
# output_clusters=[3, 4, 5, 6, 8, 25, 768]>
85-
5: {
86-
PROFILE_ID: zha.PROFILE_ID,
87-
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
88-
INPUT_CLUSTERS: [
89-
Basic.cluster_id,
90-
Identify.cluster_id,
91-
],
92-
OUTPUT_CLUSTERS: [
93-
Identify.cluster_id,
94-
Groups.cluster_id,
95-
Scenes.cluster_id,
96-
OnOff.cluster_id,
97-
LevelControl.cluster_id,
98-
Ota.cluster_id,
99-
Color.cluster_id,
100-
],
101-
},
102-
# <SimpleDescriptor endpoint=7 profile=260 device_type=515
103-
# device_version=1
104-
# input_clusters=[0, 3]
105-
# output_clusters=[3, 4, 25, 258]>
106-
7: {
107-
PROFILE_ID: zha.PROFILE_ID,
108-
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_CONTROLLER,
109-
INPUT_CLUSTERS: [
110-
Basic.cluster_id,
111-
Identify.cluster_id,
112-
],
113-
OUTPUT_CLUSTERS: [
114-
Identify.cluster_id,
115-
Groups.cluster_id,
116-
Ota.cluster_id,
117-
WindowCovering.cluster_id,
118-
],
119-
},
120-
# <SimpleDescriptor endpoint=242 profile=41440 device_type=97
121-
# device_version=1
122-
# input_clusters=[]
123-
# output_clusters=[33]>
124-
242: {
125-
PROFILE_ID: zgp.PROFILE_ID,
126-
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
127-
INPUT_CLUSTERS: [],
128-
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
129-
},
130-
},
131-
}
132-
133-
replacement = {
134-
ENDPOINTS: {
135-
4: {
136-
PROFILE_ID: zha.PROFILE_ID,
137-
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
138-
INPUT_CLUSTERS: [
139-
Basic.cluster_id,
140-
Identify.cluster_id,
141-
],
142-
OUTPUT_CLUSTERS: [
143-
Identify.cluster_id,
144-
Groups.cluster_id,
145-
Scenes.cluster_id,
146-
OnOff.cluster_id,
147-
LevelControl.cluster_id,
148-
Ota.cluster_id,
149-
Color.cluster_id,
150-
],
151-
},
152-
5: {
153-
PROFILE_ID: zha.PROFILE_ID,
154-
DEVICE_TYPE: zha.DeviceType.COLOR_DIMMER_SWITCH,
155-
INPUT_CLUSTERS: [
156-
Basic.cluster_id,
157-
Identify.cluster_id,
158-
],
159-
OUTPUT_CLUSTERS: [
160-
Identify.cluster_id,
161-
Groups.cluster_id,
162-
Scenes.cluster_id,
163-
OnOff.cluster_id,
164-
LevelControl.cluster_id,
165-
Ota.cluster_id,
166-
Color.cluster_id,
167-
],
168-
},
169-
7: {
170-
PROFILE_ID: zha.PROFILE_ID,
171-
DEVICE_TYPE: zha.DeviceType.WINDOW_COVERING_CONTROLLER,
172-
INPUT_CLUSTERS: [
173-
Basic.cluster_id,
174-
Identify.cluster_id,
175-
],
176-
OUTPUT_CLUSTERS: [
177-
Identify.cluster_id,
178-
Groups.cluster_id,
179-
Ota.cluster_id,
180-
WindowCovering.cluster_id,
181-
],
182-
},
183-
242: {
184-
PROFILE_ID: zgp.PROFILE_ID,
185-
DEVICE_TYPE: zgp.DeviceType.PROXY_BASIC,
186-
INPUT_CLUSTERS: [],
187-
OUTPUT_CLUSTERS: [GreenPowerProxy.cluster_id],
188-
},
33+
(
34+
QuirkBuilder(INSTA, "NEXENTRO Pushbutton Interface")
35+
.device_automation_triggers(
36+
{
37+
(SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON, ENDPOINT_ID: 4},
38+
(ALT_SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON, ENDPOINT_ID: 5},
39+
(SHORT_PRESS, TURN_OFF): {COMMAND: COMMAND_OFF, ENDPOINT_ID: 4},
40+
(ALT_SHORT_PRESS, TURN_OFF): {COMMAND: COMMAND_OFF, ENDPOINT_ID: 5},
41+
(SHORT_PRESS, BUTTON): {COMMAND: COMMAND_TOGGLE, ENDPOINT_ID: 4},
42+
(ALT_SHORT_PRESS, BUTTON): {COMMAND: COMMAND_TOGGLE, ENDPOINT_ID: 5},
43+
(SHORT_PRESS, OPEN): {COMMAND: COMMAND_OPEN},
44+
(SHORT_PRESS, CLOSE): {COMMAND: COMMAND_CLOSE},
45+
(SHORT_PRESS, DIM_UP): {COMMAND: COMMAND_MOVE_ON_OFF, ENDPOINT_ID: 4},
46+
(ALT_SHORT_PRESS, DIM_UP): {COMMAND: COMMAND_MOVE_ON_OFF, ENDPOINT_ID: 5},
47+
(SHORT_PRESS, DIM_DOWN): {COMMAND: COMMAND_MOVE, ENDPOINT_ID: 4},
48+
(ALT_SHORT_PRESS, DIM_DOWN): {COMMAND: COMMAND_MOVE, ENDPOINT_ID: 5},
49+
(SHORT_PRESS, STOP): {COMMAND: COMMAND_STOP, ENDPOINT_ID: 4},
50+
(ALT_SHORT_PRESS, STOP): {COMMAND: COMMAND_STOP, ENDPOINT_ID: 5},
18951
}
190-
}
191-
192-
device_automation_triggers = {
193-
(SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON, ENDPOINT_ID: 4},
194-
(ALT_SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON, ENDPOINT_ID: 5},
195-
(SHORT_PRESS, TURN_OFF): {COMMAND: COMMAND_OFF, ENDPOINT_ID: 4},
196-
(ALT_SHORT_PRESS, TURN_OFF): {COMMAND: COMMAND_OFF, ENDPOINT_ID: 5},
197-
(SHORT_PRESS, BUTTON): {COMMAND: COMMAND_TOGGLE, ENDPOINT_ID: 4},
198-
(ALT_SHORT_PRESS, BUTTON): {COMMAND: COMMAND_TOGGLE, ENDPOINT_ID: 5},
199-
(SHORT_PRESS, OPEN): {COMMAND: COMMAND_OPEN},
200-
(SHORT_PRESS, CLOSE): {COMMAND: COMMAND_CLOSE},
201-
(SHORT_PRESS, DIM_UP): {COMMAND: COMMAND_MOVE_ON_OFF, ENDPOINT_ID: 4},
202-
(ALT_SHORT_PRESS, DIM_UP): {COMMAND: COMMAND_MOVE_ON_OFF, ENDPOINT_ID: 5},
203-
(SHORT_PRESS, DIM_DOWN): {COMMAND: COMMAND_MOVE, ENDPOINT_ID: 4},
204-
(ALT_SHORT_PRESS, DIM_DOWN): {COMMAND: COMMAND_MOVE, ENDPOINT_ID: 5},
205-
(SHORT_PRESS, STOP): {COMMAND: COMMAND_STOP, ENDPOINT_ID: 4},
206-
(ALT_SHORT_PRESS, STOP): {COMMAND: COMMAND_STOP, ENDPOINT_ID: 5},
207-
}
52+
)
53+
.add_to_registry()
54+
)

zhaquirks/konke/motion.py

Lines changed: 21 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,35 @@
11
"""Konke motion sensor."""
22

3-
from zigpy.profiles import zha
4-
from zigpy.quirks import CustomDevice
5-
from zigpy.zcl.clusters.general import Basic, Identify, PowerConfiguration
3+
from typing import Any
4+
5+
from zigpy.quirks.v2 import CustomDeviceV2, QuirkBuilder
6+
from zigpy.zcl.clusters.general import PowerConfiguration
67
from zigpy.zcl.clusters.security import IasZone
78

89
from zhaquirks import Bus, PowerConfigurationCluster
9-
from zhaquirks.const import (
10-
DEVICE_TYPE,
11-
ENDPOINTS,
12-
INPUT_CLUSTERS,
13-
MODELS_INFO,
14-
OUTPUT_CLUSTERS,
15-
PROFILE_ID,
16-
)
1710
from zhaquirks.konke import KONKE, MotionCluster, OccupancyCluster
1811

19-
KONKE_CLUSTER_ID = 0xFCC0
20-
21-
22-
class KonkeMotion(CustomDevice):
23-
"""Custom device representing konke motion sensors."""
24-
25-
def __init__(self, *args, **kwargs):
26-
"""Init."""
27-
self.occupancy_bus = Bus()
28-
super().__init__(*args, **kwargs)
29-
30-
signature = {
31-
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
32-
# device_version=0
33-
# input_clusters=[0, 1, 3, 1280, 64704]
34-
# output_clusters=[3, 64704]>
35-
MODELS_INFO: [
36-
(KONKE, "3AFE28010402000D"),
37-
(KONKE, "3AFE14010402000D"),
38-
(KONKE, "3AFE27010402000D"),
39-
],
40-
ENDPOINTS: {
41-
1: {
42-
PROFILE_ID: zha.PROFILE_ID,
43-
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
44-
INPUT_CLUSTERS: [
45-
Basic.cluster_id,
46-
PowerConfiguration.cluster_id,
47-
Identify.cluster_id,
48-
IasZone.cluster_id,
49-
KONKE_CLUSTER_ID,
50-
],
51-
OUTPUT_CLUSTERS: [Identify.cluster_id, KONKE_CLUSTER_ID],
52-
}
53-
},
54-
}
5512

56-
replacement = {
57-
ENDPOINTS: {
58-
1: {
59-
INPUT_CLUSTERS: [
60-
Basic.cluster_id,
61-
PowerConfigurationCluster,
62-
Identify.cluster_id,
63-
OccupancyCluster,
64-
MotionCluster,
65-
KONKE_CLUSTER_ID,
66-
],
67-
OUTPUT_CLUSTERS: [Identify.cluster_id, KONKE_CLUSTER_ID],
68-
}
69-
}
70-
}
13+
class KonkeMotionDevice(CustomDeviceV2):
14+
"""Custom device class for Konke motion sensors that need occupancy_bus."""
7115

72-
73-
class KonkeMotionB(CustomDevice):
74-
"""Custom device representing konke motion sensors."""
75-
76-
def __init__(self, *args, **kwargs):
16+
def __init__(self, *args: Any, **kwargs: Any) -> None:
7717
"""Init."""
7818
self.occupancy_bus = Bus()
7919
super().__init__(*args, **kwargs)
8020

81-
signature = {
82-
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
83-
# device_version=0
84-
# input_clusters=[0, 1, 3, 1280]
85-
# output_clusters=[3]>
86-
MODELS_INFO: [
87-
(KONKE, "3AFE28010402000D"),
88-
(KONKE, "3AFE14010402000D"),
89-
(KONKE, "3AFE27010402000D"),
90-
],
91-
ENDPOINTS: {
92-
1: {
93-
PROFILE_ID: zha.PROFILE_ID,
94-
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
95-
INPUT_CLUSTERS: [
96-
Basic.cluster_id,
97-
PowerConfiguration.cluster_id,
98-
Identify.cluster_id,
99-
IasZone.cluster_id,
100-
],
101-
OUTPUT_CLUSTERS: [Identify.cluster_id],
102-
}
103-
},
104-
}
10521

106-
replacement = {
107-
ENDPOINTS: {
108-
1: {
109-
INPUT_CLUSTERS: [
110-
Basic.cluster_id,
111-
PowerConfigurationCluster,
112-
Identify.cluster_id,
113-
OccupancyCluster,
114-
MotionCluster,
115-
],
116-
OUTPUT_CLUSTERS: [Identify.cluster_id],
117-
}
118-
}
119-
}
22+
(
23+
QuirkBuilder(KONKE, "3AFE28010402000D")
24+
.applies_to(KONKE, "3AFE14010402000D")
25+
.applies_to(KONKE, "3AFE27010402000D")
26+
.device_class(KonkeMotionDevice)
27+
.replaces(
28+
PowerConfigurationCluster,
29+
cluster_id=PowerConfiguration.cluster_id,
30+
endpoint_id=1,
31+
)
32+
.replaces(MotionCluster, cluster_id=IasZone.cluster_id, endpoint_id=1)
33+
.adds(OccupancyCluster, endpoint_id=1)
34+
.add_to_registry()
35+
)

0 commit comments

Comments
 (0)