Skip to content

Commit 00bdde2

Browse files
committed
Merge branch 'release/0.0.72'
2 parents 1cb1d7f + 18f3aad commit 00bdde2

25 files changed

+352
-149
lines changed

README.md

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ The second part is the event data. You only need to supply enough of the event d
418418

419419
If you look at another example for the same device:
420420

421-
`(SHORT_PRESS, DIM_UP): {COMMAND: COMMAND_STEP, CLUSTER_ID: 8, ENDPOINT_ID: 1, ARGS: [0, 30, 9],}`
421+
`(SHORT_PRESS, DIM_UP): {COMMAND: COMMAND_STEP, CLUSTER_ID: 8, ENDPOINT_ID: 1, PARAMS: {'step_mode': 0},}`
422422

423423
You can see a pattern that illustrates how to match a more complex event. In this case the step command is used for the dim up and dim down buttons so we need to match more of the event data to uniquely match the event.
424424

@@ -535,54 +535,6 @@ def test_ts0121_signature(assert_signature_matches_quirk):
535535
assert_signature_matches_quirk(zhaquirks.tuya.ts0121_plug.Plug, signature)
536536
```
537537

538-
# Testing new releases
539-
540-
Testing a new release of the zha-quirks package before it is released in Home Assistant.
541-
542-
If you are using Supervised Home Assistant (formerly known as the Hassio/Hass.io distro):
543-
544-
- Add <https://github.com/home-assistant/hassio-addons-development> as "add-on" repository
545-
- Install "Custom deps deployment" addon
546-
- Update config like:
547-
548-
```yml
549-
pypi:
550-
- zha-quirks==0.0.38
551-
apk: []
552-
```
553-
554-
where 0.0.38 is the new version
555-
556-
- Start the addon
557-
558-
If you are instead using some custom python installation of Home Assistant then do this:
559-
560-
- Activate your python virtual env
561-
- Update package with `pip`
562-
563-
```bash
564-
pip install zha-quirks==0.0.38
565-
```
566-
567-
# Testing quirks in development in docker based install
568-
569-
If you are using Supervised Home Assistant (formerly known as the Hassio/Hass.io distro) you will need to get access to the home-assistant docker container. Directions below are given for using the portainer add-on to do this, there are other methods as well not covered here.
570-
571-
- Install the portainer add-on (<https://github.com/hassio-addons/addon-portainer>) from Home Assistant Community Add-ons.
572-
- Follow the add-on documentation to un-hide the home-assistant container (<https://github.com/hassio-addons/addon-portainer/blob/master/portainer/DOCS.md>)
573-
- Stage the update quirk in a directory within your config directory
574-
- Use portainer to access a console in the home-assistant container:
575-
576-
<img src="https://user-images.githubusercontent.com/11084412/88719260-fdfa7700-d0f0-11ea-8791-88ed3e26915d.png" width=400 >
577-
578-
- Access the quirks directory
579-
- on HA > 0.113: /usr/local/lib/python3.8/site-packages/zhaquirks/
580-
- on HA < 0.113: /usr/local/lib/python3.7/site-packages/zhaquirks/
581-
- Copy updated/new quirk to zhaquirks directory: `cp -a /config/temp/NEW_QUIRK ./`
582-
- Remove the **pycache** folder so it is regenerated `rm -rf ./__pycache__/`
583-
- Close out the console and restart HA.
584-
- Note: The added/update quirk will not survive a HA version update.
585-
586538
# Thanks
587539

588540
- Special thanks to damarco for the majority of the device tracker code

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from setuptools import find_packages, setup
66

7-
VERSION = "0.0.71"
7+
VERSION = "0.0.72"
88

99

1010
setup(
@@ -20,6 +20,6 @@
2020
keywords="zha quirks homeassistant hass",
2121
packages=find_packages(exclude=["tests"]),
2222
python_requires=">=3",
23-
install_requires=["zigpy>=0.44.1"],
23+
install_requires=["zigpy>=0.44.2"],
2424
tests_require=["pytest"],
2525
)

tests/test_quirks.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@
1818
import zhaquirks
1919
import zhaquirks.bosch.motion
2020
from zhaquirks.const import (
21+
ARGS,
22+
COMMAND,
23+
COMMAND_MOVE,
24+
COMMAND_MOVE_COLOR_TEMP,
25+
COMMAND_MOVE_ON_OFF,
26+
COMMAND_MOVE_SATURATION,
27+
COMMAND_MOVE_TO_LEVEL_ON_OFF,
28+
COMMAND_MOVE_TO_SATURATION,
29+
COMMAND_STEP,
30+
COMMAND_STEP_COLOR_TEMP,
31+
COMMAND_STEP_HUE,
32+
COMMAND_STEP_ON_OFF,
33+
COMMAND_STEP_SATURATION,
34+
COMMAND_STOP,
35+
COMMAND_STOP_ON_OFF,
2136
DEVICE_TYPE,
2237
ENDPOINTS,
2338
INPUT_CLUSTERS,
@@ -26,6 +41,7 @@
2641
MODELS_INFO,
2742
NODE_DESCRIPTOR,
2843
OUTPUT_CLUSTERS,
44+
PARAMS,
2945
PROFILE_ID,
3046
SKIP_CONFIGURATION,
3147
)
@@ -517,3 +533,48 @@ def test_no_module_level_device_automation_triggers(module_name: str) -> None:
517533

518534
mod = importlib.import_module(module_name)
519535
assert not hasattr(mod, "device_automation_triggers")
536+
537+
538+
@pytest.mark.parametrize("quirk", ALL_QUIRK_CLASSES)
539+
def test_migrated_lighting_automation_triggers(quirk: CustomDevice) -> None:
540+
"""Ensure quirks with lighting or level control clusters are using PARAMS."""
541+
542+
if not hasattr(quirk, "device_automation_triggers"):
543+
return
544+
545+
for trigger, event in quirk.device_automation_triggers.items():
546+
if COMMAND not in event:
547+
continue
548+
549+
command = event[COMMAND]
550+
551+
# We only consider lighting commands for now
552+
if command in (
553+
COMMAND_MOVE_SATURATION,
554+
COMMAND_MOVE_TO_SATURATION,
555+
COMMAND_MOVE_COLOR_TEMP,
556+
COMMAND_STEP_HUE,
557+
COMMAND_STEP_SATURATION,
558+
COMMAND_STEP_COLOR_TEMP,
559+
):
560+
cluster = zcl.clusters.lighting.Color
561+
elif command in (
562+
COMMAND_MOVE,
563+
COMMAND_MOVE_ON_OFF,
564+
COMMAND_STEP,
565+
COMMAND_STEP_ON_OFF,
566+
COMMAND_STOP,
567+
COMMAND_STOP_ON_OFF,
568+
COMMAND_MOVE_TO_LEVEL_ON_OFF,
569+
):
570+
cluster = zcl.clusters.general.LevelControl
571+
else:
572+
continue
573+
574+
if ARGS in event:
575+
raise ValueError(f"ARGS should be migrated to PARAMS: {command!r}")
576+
elif PARAMS not in event:
577+
continue
578+
579+
schema = cluster.commands_by_name[command].schema
580+
schema(**event[PARAMS])

tests/test_tuya_mcu.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,15 @@ async def test_tuya_mcu_classes():
125125
mcu_version = TuyaMCUCluster.MCUVersion()
126126
assert mcu_version
127127
assert not mcu_version.version
128+
129+
# test TuyaClusterData.manufacturer values
130+
t_c_d = TuyaClusterData(manufacturer=foundation.ZCLHeader.NO_MANUFACTURER_ID)
131+
assert t_c_d.manufacturer == -1
132+
t_c_d = TuyaClusterData(manufacturer=4619)
133+
assert t_c_d.manufacturer == 4619
134+
t_c_d = TuyaClusterData(manufacturer="4098")
135+
assert t_c_d.manufacturer == 4098
136+
with pytest.raises(ValueError):
137+
TuyaClusterData(manufacturer="xiaomi")
138+
with pytest.raises(ValueError):
139+
TuyaClusterData(manufacturer=b"")

zhaquirks/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
MODELS_INFO,
3232
MOTION_EVENT,
3333
NODE_DESCRIPTOR,
34+
OCCUPANCY_EVENT,
35+
OCCUPANCY_STATE,
3436
OFF,
3537
ON,
3638
OUTPUT_CLUSTERS,
@@ -42,8 +44,6 @@
4244
)
4345

4446
_LOGGER = logging.getLogger(__name__)
45-
OCCUPANCY_STATE = 0
46-
OCCUPANCY_EVENT = "occupancy_event"
4747

4848

4949
class Bus(ListenableMixin):

zhaquirks/adeo/color_controller.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
INPUT_CLUSTERS,
4343
MODELS_INFO,
4444
OUTPUT_CLUSTERS,
45+
PARAMS,
4546
PROFILE_ID,
4647
SHORT_PRESS,
4748
TURN_OFF,
@@ -188,49 +189,61 @@ def __init__(self, *args, **kwargs):
188189
COMMAND: COMMAND_STEP,
189190
CLUSTER_ID: 8, # LevelControl.cluster_id
190191
ENDPOINT_ID: 1,
191-
ARGS: [0, 26, 5],
192+
PARAMS: {"step_mode": 0, "step_size": 26, "transition_time": 5},
192193
},
193194
(SHORT_PRESS, DIM_DOWN): {
194195
COMMAND: COMMAND_STEP,
195196
CLUSTER_ID: 8, # LevelControl.cluster_id
196197
ENDPOINT_ID: 1,
197-
ARGS: [1, 26, 5],
198+
PARAMS: {"step_mode": 1, "step_size": 26, "transition_time": 5},
198199
},
199200
(SHORT_PRESS, COLOR_UP): {
200201
COMMAND: COMMAND_STEP_COLOR_TEMP,
201202
CLUSTER_ID: 768, # Color.cluster_id
202203
ENDPOINT_ID: 1,
203-
ARGS: [3, 22, 5, 153, 370],
204+
PARAMS: {
205+
"step_mode": 3,
206+
"step_size": 22,
207+
"transition_time": 5,
208+
"color_temp_min_mireds": 153,
209+
"color_temp_max_mireds": 370,
210+
},
204211
},
205212
(SHORT_PRESS, COLOR_DOWN): {
206213
COMMAND: COMMAND_STEP_COLOR_TEMP,
207214
CLUSTER_ID: 768, # Color.cluster_id
208215
ENDPOINT_ID: 1,
209-
ARGS: [1, 22, 5, 153, 370],
216+
PARAMS: {
217+
"step_mode": 1,
218+
"step_size": 22,
219+
"transition_time": 5,
220+
"color_temp_min_mireds": 153,
221+
"color_temp_max_mireds": 370,
222+
},
210223
},
211224
(SHORT_PRESS, SATURATION_UP): {
212225
COMMAND: COMMAND_STEP_SATURATION,
213226
CLUSTER_ID: 768, # Color.cluster_id
214227
ENDPOINT_ID: 1,
215-
ARGS: [1, 26, 5],
228+
PARAMS: {"step_mode": 1, "step_size": 26, "transition_time": 5},
216229
},
217230
(SHORT_PRESS, SATURATION_DOWN): {
218231
COMMAND: COMMAND_STEP_SATURATION,
219232
CLUSTER_ID: 768, # Color.cluster_id
220233
ENDPOINT_ID: 1,
221-
ARGS: [3, 26, 5],
234+
PARAMS: {"step_mode": 3, "step_size": 26, "transition_time": 5},
222235
},
223236
(SHORT_PRESS, HUE_LEFT): {
224237
COMMAND: COMMAND_STEP_HUE,
225238
CLUSTER_ID: 768, # Color.cluster_id
226239
ENDPOINT_ID: 1,
227-
ARGS: [3, 22, 5],
240+
PARAMS: {"step_mode": 3, "step_size": 22, "transition_time": 5},
228241
},
229242
(SHORT_PRESS, HUE_RIGHT): {
230243
COMMAND: COMMAND_STEP_HUE,
231244
CLUSTER_ID: 768, # Color.cluster_id
232245
ENDPOINT_ID: 1,
233-
ARGS: [1, 22, 5],
246+
PARAMS: {"step_mode": 1, "step_size": 22, "transition_time": 5},
234247
},
235248
(SHORT_PRESS, BUTTON_1): {
236249
COMMAND: "view",

zhaquirks/aduro/adurolightncc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from zigpy.zcl.clusters.lightlink import LightLink
77

88
from zhaquirks.const import (
9-
ARGS,
109
CLUSTER_ID,
1110
COMMAND,
1211
COMMAND_OFF,
@@ -20,6 +19,7 @@
2019
INPUT_CLUSTERS,
2120
MODELS_INFO,
2221
OUTPUT_CLUSTERS,
22+
PARAMS,
2323
PROFILE_ID,
2424
SHORT_PRESS,
2525
TURN_OFF,
@@ -91,12 +91,12 @@ class AdurolightNCC(CustomDevice):
9191
COMMAND: COMMAND_STEP,
9292
CLUSTER_ID: 8,
9393
ENDPOINT_ID: 1,
94-
ARGS: [0, 16, 9],
94+
PARAMS: {"step_mode": 0, "step_size": 16, "transition_time": 9},
9595
},
9696
(SHORT_PRESS, DIM_DOWN): {
9797
COMMAND: COMMAND_STEP,
9898
CLUSTER_ID: 8,
9999
ENDPOINT_ID: 1,
100-
ARGS: [1, 16, 9],
100+
PARAMS: {"step_mode": 1, "step_size": 16, "transition_time": 9},
101101
},
102102
}

zhaquirks/aurora/aurora_dimmer.py

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
LEFT,
2828
MODELS_INFO,
2929
OUTPUT_CLUSTERS,
30+
PARAMS,
3031
PROFILE_ID,
3132
RIGHT,
3233
SHORT_PRESS,
@@ -177,49 +178,73 @@ class WallSwitchColorCluster(EventableCluster, Color):
177178
COMMAND: COMMAND_STEP,
178179
CLUSTER_ID: 8,
179180
ENDPOINT_ID: 1,
180-
ARGS: [0, 26, 3],
181+
PARAMS: {"step_mode": 0, "step_size": 26, "transition_time": 3},
181182
},
182183
(DIM_DOWN, RIGHT): {
183184
COMMAND: COMMAND_STEP,
184185
CLUSTER_ID: 8,
185186
ENDPOINT_ID: 1,
186-
ARGS: [1, 26, 3],
187+
PARAMS: {"step_mode": 1, "step_size": 26, "transition_time": 3},
187188
},
188189
(COLOR_UP, RIGHT): {
189190
COMMAND: COMMAND_STEP_COLOR_TEMP,
190191
CLUSTER_ID: 768,
191192
ENDPOINT_ID: 1,
192-
ARGS: [3, 47, 3, 153, 454],
193+
PARAMS: {
194+
"step_mode": 3,
195+
"step_size": 47,
196+
"transition_time": 3,
197+
"color_temp_min_mireds": 153,
198+
"color_temp_max_mireds": 454,
199+
},
193200
},
194201
(COLOR_DOWN, RIGHT): {
195202
COMMAND: COMMAND_STEP_COLOR_TEMP,
196203
CLUSTER_ID: 768,
197204
ENDPOINT_ID: 1,
198-
ARGS: [1, 47, 3, 153, 454],
205+
PARAMS: {
206+
"step_mode": 1,
207+
"step_size": 47,
208+
"transition_time": 3,
209+
"color_temp_min_mireds": 153,
210+
"color_temp_max_mireds": 454,
211+
},
199212
},
200213
(DIM_UP, LEFT): {
201214
COMMAND: COMMAND_STEP,
202215
CLUSTER_ID: 8,
203216
ENDPOINT_ID: 2,
204-
ARGS: [0, 26, 3],
217+
PARAMS: {"step_mode": 0, "step_size": 26, "transition_time": 3},
205218
},
206219
(DIM_DOWN, LEFT): {
207220
COMMAND: COMMAND_STEP,
208221
CLUSTER_ID: 8,
209222
ENDPOINT_ID: 2,
210-
ARGS: [1, 26, 3],
223+
PARAMS: {"step_mode": 1, "step_size": 26, "transition_time": 3},
211224
},
212225
(COLOR_UP, LEFT): {
213226
COMMAND: COMMAND_STEP_COLOR_TEMP,
214227
CLUSTER_ID: 768,
215228
ENDPOINT_ID: 1,
216-
ARGS: [3, 47, 3, 153, 454],
229+
PARAMS: {
230+
"step_mode": 3,
231+
"step_size": 47,
232+
"transition_time": 3,
233+
"color_temp_min_mireds": 153,
234+
"color_temp_max_mireds": 454,
235+
},
217236
},
218237
(COLOR_DOWN, LEFT): {
219238
COMMAND: COMMAND_STEP_COLOR_TEMP,
220239
CLUSTER_ID: 768,
221240
ENDPOINT_ID: 1,
222-
ARGS: [1, 47, 3, 153, 454],
241+
PARAMS: {
242+
"step_mode": 1,
243+
"step_size": 47,
244+
"transition_time": 3,
245+
"color_temp_min_mireds": 153,
246+
"color_temp_max_mireds": 454,
247+
},
223248
},
224249
(SHORT_PRESS, RIGHT): {
225250
CLUSTER_ID: 6,

0 commit comments

Comments
 (0)