Skip to content

Commit 2af0d41

Browse files
committed
Minimize diff
1 parent 8fb5e10 commit 2af0d41

File tree

4 files changed

+27
-56
lines changed

4 files changed

+27
-56
lines changed

tests/conftest.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ def _dev(
171171
model: str,
172172
endpoint_ids: list[int] = [1],
173173
cluster_ids: dict[int, dict[int, ClusterType]] = {},
174-
device_types: dict[int, int] = {},
175174
ieee=None,
176175
nwk=zigpy.types.NWK(0x1234),
177176
apply_quirk=True,
@@ -185,8 +184,6 @@ def _dev(
185184
and their cluster ids and types to be added to the device.
186185
More advanced version of endpoint_ids argument.
187186
Example: `cluster_ids={2: {OnOff.cluster_id: ClusterType.Client}}`
188-
:param device_types: Dictionary mapping endpoint ids to device_type values.
189-
Example: `device_types={1: 0x0820}`
190187
:param ieee: IEEE address of the device.
191188
:param nwk: Network address of the device.
192189
:param apply_quirk: Whether to apply the quirk to the device.
@@ -215,21 +212,30 @@ def _dev(
215212
for endpoint_id, clusters in endpoint_clusters.items():
216213
ep = raw_device.add_endpoint(endpoint_id)
217214

218-
# set device_type if provided
219-
if endpoint_id in device_types:
220-
ep.device_type = device_types[endpoint_id]
221-
222215
# add custom cluster ids to test device
223216
for cluster_id, cluster_type in clusters.items():
224217
if cluster_type == ClusterType.Client:
225218
ep.add_output_cluster(cluster_id)
226219
else:
227220
ep.add_input_cluster(cluster_id)
228221

222+
quirked = zigpy.quirks.get_device(raw_device)
223+
229224
if not apply_quirk:
225+
for ep_id, ep_data in quirked.endpoints.items():
226+
if ep_id != 0:
227+
ep = raw_device.add_endpoint(ep_id)
228+
ep.profile_id = ep_data.get(PROFILE_ID, 0x0260)
229+
ep.device_type = ep_data.get(DEVICE_TYPE, 0xFEDB)
230+
in_clusters = ep_data.get(INPUT_CLUSTERS, [])
231+
for cluster_id in in_clusters:
232+
ep.add_input_cluster(cluster_id)
233+
out_clusters = ep_data.get(OUTPUT_CLUSTERS, [])
234+
for cluster_id in out_clusters:
235+
ep.add_output_cluster(cluster_id)
230236
return raw_device
231-
232-
quirked = zigpy.quirks.get_device(raw_device)
237+
else:
238+
assert isinstance(quirked, zigpy.quirks.BaseCustomDevice)
233239

234240
MockAppController.devices[ieee] = quirked
235241

tests/test_philips.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from unittest import mock
44

55
import pytest
6-
from zigpy.profiles import zha
76
from zigpy.quirks import CustomEndpoint
87
from zigpy.zcl import Cluster
98
from zigpy.zcl.clusters.general import OnOff
@@ -377,9 +376,7 @@ def test_PhilipsRemoteCluster_short_press(
377376
):
378377
"""Test PhilipsRemoteCluster short button press logic."""
379378

380-
device = zigpy_device_from_v2_quirk(
381-
manufacturer, model, endpoint_ids=[1, 2], device_types={1: zha.DeviceType.NON_COLOR_CONTROLLER}
382-
)
379+
device = zigpy_device_from_v2_quirk(manufacturer, model, endpoint_ids=[1, 2])
383380

384381
cluster = device.endpoints[ep].philips_remote_cluster
385382
listener = mock.MagicMock()
@@ -476,9 +473,7 @@ def test_PhilipsRemoteCluster_multi_press(
476473
):
477474
"""Test PhilipsRemoteCluster button multi-press logic."""
478475

479-
device = zigpy_device_from_v2_quirk(
480-
manufacturer, model, endpoint_ids=[1, 2], device_types={1: zha.DeviceType.NON_COLOR_CONTROLLER}
481-
)
476+
device = zigpy_device_from_v2_quirk(manufacturer, model, endpoint_ids=[1, 2])
482477

483478
cluster = device.endpoints[ep].philips_remote_cluster
484479
listener = mock.MagicMock()
@@ -523,12 +518,12 @@ def test_PhilipsRemoteCluster_multi_press(
523518
(SIGNIFY, "RWL022", 1),
524519
),
525520
)
526-
def test_PhilipsRemoteCluster_ignore_unknown_buttons(zigpy_device_from_v2_quirk, manufacturer, model, ep):
521+
def test_PhilipsRemoteCluster_ignore_unknown_buttons(
522+
zigpy_device_from_v2_quirk, manufacturer, model, ep
523+
):
527524
"""Ensure PhilipsRemoteCluster ignores unknown buttons."""
528525

529-
device = zigpy_device_from_v2_quirk(
530-
manufacturer, model, endpoint_ids=[1, 2], device_types={1: zha.DeviceType.NON_COLOR_CONTROLLER}
531-
)
526+
device = zigpy_device_from_v2_quirk(manufacturer, model, endpoint_ids=[1, 2])
532527

533528
cluster = device.endpoints[ep].philips_remote_cluster
534529
listener = mock.MagicMock()
@@ -602,9 +597,7 @@ def test_PhilipsRemoteCluster_long_press(
602597
):
603598
"""Test PhilipsRemoteCluster button long press logic."""
604599

605-
device = zigpy_device_from_v2_quirk(
606-
manufacturer, model, endpoint_ids=[1, 2], device_types={1: zha.DeviceType.NON_COLOR_CONTROLLER}
607-
)
600+
device = zigpy_device_from_v2_quirk(manufacturer, model, endpoint_ids=[1, 2])
608601

609602
cluster = device.endpoints[ep].philips_remote_cluster
610603
listener = mock.MagicMock()
@@ -806,9 +799,7 @@ def test_PhilipsRemoteCluster_multi_button_press(
806799
):
807800
"""Test PhilipsRemoteCluster short button press logic."""
808801

809-
device = zigpy_device_from_v2_quirk(
810-
manufacturer, model, endpoint_ids=[1, 2], device_types={1: zha.DeviceType.NON_COLOR_CONTROLLER}
811-
)
802+
device = zigpy_device_from_v2_quirk(manufacturer, model, endpoint_ids=[1, 2])
812803

813804
remote_cluster = device.endpoints[ep].philips_remote_cluster
814805
remote_cluster.button_press_queue = {

zhaquirks/danfoss/thermostat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,9 @@ class DanfossThermostat(CustomDeviceV2):
481481
.applies_to(POPP, "eT093WRG")
482482
.applies_to(HIVE, "TRV001")
483483
.applies_to(HIVE, "TRV003")
484-
.replaces(DanfossTimeCluster, endpoint_id=1) # was Time
485-
.replaces(DanfossThermostatCluster, endpoint_id=1) # was Thermostat
486-
.replaces(DanfossUserInterfaceCluster, endpoint_id=1) # was UserInterface
487-
.replaces(DanfossDiagnosticCluster, endpoint_id=1) # was Diagnostic
484+
.replaces(DanfossTimeCluster, endpoint_id=1)
485+
.replaces(DanfossThermostatCluster, endpoint_id=1)
486+
.replaces(DanfossUserInterfaceCluster, endpoint_id=1)
487+
.replaces(DanfossDiagnosticCluster, endpoint_id=1)
488488
.add_to_registry()
489489
)

zhaquirks/philips/wall_switch.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from typing import Final
44

5-
from zigpy.profiles import zha
65
from zigpy.quirks.v2 import QuirkBuilder
76
import zigpy.types as t
87
from zigpy.zcl.foundation import ZCLAttributeDef
@@ -82,31 +81,6 @@ class PhilipsWallSwitchRemoteCluster(PhilipsRemoteCluster):
8281
.applies_to(SIGNIFY, "RDM001")
8382
.applies_to(PHILIPS, "RDM004") # likely not needed
8483
.applies_to(SIGNIFY, "RDM004")
85-
# TODO: use real firmware version filters
86-
.filter(
87-
lambda device: device.endpoints[1].device_type
88-
== zha.DeviceType.NON_COLOR_CONTROLLER
89-
)
90-
.replaces(PhilipsWallSwitchBasicCluster, endpoint_id=1)
91-
.replaces(PhilipsWallSwitchRemoteCluster, endpoint_id=1)
92-
.device_automation_triggers(
93-
PhilipsWallSwitchRemoteCluster.generate_device_automation_triggers()
94-
)
95-
.add_to_registry()
96-
)
97-
98-
99-
# Philips RDM001 or RDM004 device using new firmware.
100-
(
101-
QuirkBuilder(PHILIPS, "RDM001")
102-
.applies_to(SIGNIFY, "RDM001")
103-
.applies_to(PHILIPS, "RDM004") # likely not needed
104-
.applies_to(SIGNIFY, "RDM004")
105-
# TODO: use real firmware version filters
106-
.filter(
107-
lambda device: device.endpoints[1].device_type
108-
== zha.DeviceType.NON_COLOR_SCENE_CONTROLLER
109-
)
11084
.replaces(PhilipsWallSwitchBasicCluster, endpoint_id=1)
11185
.replaces(PhilipsWallSwitchRemoteCluster, endpoint_id=1)
11286
.device_automation_triggers(

0 commit comments

Comments
 (0)