Skip to content

Commit ee907b4

Browse files
authored
Ignore endpoint profiles other than ZHA or ZLL (#413)
* Ignore profiles other than ZHA and ZLL * Fix unit tests * Fix more unit tests * Fix more unit tests * Fix remaining tests * Fix broken Frient devices
1 parent d729263 commit ee907b4

13 files changed

+53
-159
lines changed

tests/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import zigpy.device
1818
import zigpy.group
1919
import zigpy.profiles
20+
from zigpy.profiles.zha import PROFILE_ID as ZHA_PROFILE_ID
2021
import zigpy.types
2122
from zigpy.zcl.clusters.general import Basic, Groups
2223
from zigpy.zcl.foundation import Status
@@ -237,6 +238,7 @@ async def zigpy_app_controller_fixture():
237238
ep = dev.add_endpoint(1)
238239
ep.add_input_cluster(Basic.cluster_id)
239240
ep.add_input_cluster(Groups.cluster_id)
241+
ep.profile_id = ZHA_PROFILE_ID
240242

241243
with patch("zigpy.device.Device.request", return_value=[Status.SUCCESS]):
242244
yield app

tests/data/devices/frient-a-s-aqszb-110.json

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@
836836
{
837837
"info_object": {
838838
"fallback_name": null,
839-
"unique_id": "00:15:bc:00:36:00:1f:ee-1-3",
839+
"unique_id": "00:15:bc:00:36:00:1f:ee-38-3",
840840
"platform": "button",
841841
"class_name": "IdentifyButton",
842842
"translation_key": null,
@@ -849,14 +849,14 @@
849849
{
850850
"class_name": "IdentifyClusterHandler",
851851
"generic_id": "cluster_handler_0x0003",
852-
"endpoint_id": 1,
852+
"endpoint_id": 38,
853853
"cluster": {
854854
"id": 3,
855855
"name": "Identify",
856856
"type": "server"
857857
},
858-
"id": "1:0x0003",
859-
"unique_id": "00:15:bc:00:36:00:1f:ee:1:0x0003",
858+
"id": "38:0x0003",
859+
"unique_id": "00:15:bc:00:36:00:1f:ee:38:0x0003",
860860
"status": "CREATED",
861861
"value_attribute": null
862862
}
@@ -871,7 +871,7 @@
871871
21,
872872
0
873873
],
874-
"endpoint_id": 1,
874+
"endpoint_id": 38,
875875
"available": false,
876876
"group_id": null,
877877
"command": "identify",
@@ -1154,56 +1154,6 @@
11541154
}
11551155
}
11561156
],
1157-
"switch": [
1158-
{
1159-
"info_object": {
1160-
"fallback_name": null,
1161-
"unique_id": "00:15:bc:00:36:00:1f:ee-1-6",
1162-
"platform": "switch",
1163-
"class_name": "Switch",
1164-
"translation_key": "switch",
1165-
"device_class": null,
1166-
"state_class": null,
1167-
"entity_category": null,
1168-
"entity_registry_enabled_default": true,
1169-
"enabled": true,
1170-
"cluster_handlers": [
1171-
{
1172-
"class_name": "OnOffClusterHandler",
1173-
"generic_id": "cluster_handler_0x0006",
1174-
"endpoint_id": 1,
1175-
"cluster": {
1176-
"id": 6,
1177-
"name": "On/Off",
1178-
"type": "server"
1179-
},
1180-
"id": "1:0x0006",
1181-
"unique_id": "00:15:bc:00:36:00:1f:ee:1:0x0006",
1182-
"status": "CREATED",
1183-
"value_attribute": "on_off"
1184-
}
1185-
],
1186-
"device_ieee": [
1187-
238,
1188-
31,
1189-
0,
1190-
54,
1191-
0,
1192-
188,
1193-
21,
1194-
0
1195-
],
1196-
"endpoint_id": 1,
1197-
"available": false,
1198-
"group_id": null
1199-
},
1200-
"state": {
1201-
"class_name": "Switch",
1202-
"state": false,
1203-
"available": false
1204-
}
1205-
}
1206-
],
12071157
"update": [
12081158
{
12091159
"info_object": {

tests/data/devices/frient-a-s-flszb-110.json

Lines changed: 4 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@
11621162
{
11631163
"info_object": {
11641164
"fallback_name": null,
1165-
"unique_id": "00:15:bc:00:33:00:76:9a-1-3",
1165+
"unique_id": "00:15:bc:00:33:00:76:9a-35-3",
11661166
"platform": "button",
11671167
"class_name": "IdentifyButton",
11681168
"translation_key": null,
@@ -1175,14 +1175,14 @@
11751175
{
11761176
"class_name": "IdentifyClusterHandler",
11771177
"generic_id": "cluster_handler_0x0003",
1178-
"endpoint_id": 1,
1178+
"endpoint_id": 35,
11791179
"cluster": {
11801180
"id": 3,
11811181
"name": "Identify",
11821182
"type": "server"
11831183
},
1184-
"id": "1:0x0003",
1185-
"unique_id": "00:15:bc:00:33:00:76:9a:1:0x0003",
1184+
"id": "35:0x0003",
1185+
"unique_id": "00:15:bc:00:33:00:76:9a:35:0x0003",
11861186
"status": "CREATED",
11871187
"value_attribute": null
11881188
}
@@ -1709,56 +1709,6 @@
17091709
}
17101710
}
17111711
],
1712-
"switch": [
1713-
{
1714-
"info_object": {
1715-
"fallback_name": null,
1716-
"unique_id": "00:15:bc:00:33:00:76:9a-1-6",
1717-
"platform": "switch",
1718-
"class_name": "Switch",
1719-
"translation_key": "switch",
1720-
"device_class": null,
1721-
"state_class": null,
1722-
"entity_category": null,
1723-
"entity_registry_enabled_default": true,
1724-
"enabled": true,
1725-
"cluster_handlers": [
1726-
{
1727-
"class_name": "OnOffClusterHandler",
1728-
"generic_id": "cluster_handler_0x0006",
1729-
"endpoint_id": 1,
1730-
"cluster": {
1731-
"id": 6,
1732-
"name": "On/Off",
1733-
"type": "server"
1734-
},
1735-
"id": "1:0x0006",
1736-
"unique_id": "00:15:bc:00:33:00:76:9a:1:0x0006",
1737-
"status": "CREATED",
1738-
"value_attribute": "on_off"
1739-
}
1740-
],
1741-
"device_ieee": [
1742-
154,
1743-
118,
1744-
0,
1745-
51,
1746-
0,
1747-
188,
1748-
21,
1749-
0
1750-
],
1751-
"endpoint_id": 1,
1752-
"available": false,
1753-
"group_id": null
1754-
},
1755-
"state": {
1756-
"class_name": "Switch",
1757-
"state": false,
1758-
"available": false
1759-
}
1760-
}
1761-
],
17621712
"update": [
17631713
{
17641714
"info_object": {

tests/data/devices/frient-a-s-splzb-141.json

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,54 +2517,6 @@
25172517
}
25182518
],
25192519
"switch": [
2520-
{
2521-
"info_object": {
2522-
"fallback_name": null,
2523-
"unique_id": "00:15:bc:00:2f:02:19:79-1-6",
2524-
"platform": "switch",
2525-
"class_name": "Switch",
2526-
"translation_key": "switch",
2527-
"device_class": null,
2528-
"state_class": null,
2529-
"entity_category": null,
2530-
"entity_registry_enabled_default": true,
2531-
"enabled": true,
2532-
"cluster_handlers": [
2533-
{
2534-
"class_name": "OnOffClusterHandler",
2535-
"generic_id": "cluster_handler_0x0006",
2536-
"endpoint_id": 1,
2537-
"cluster": {
2538-
"id": 6,
2539-
"name": "On/Off",
2540-
"type": "server"
2541-
},
2542-
"id": "1:0x0006",
2543-
"unique_id": "00:15:bc:00:2f:02:19:79:1:0x0006",
2544-
"status": "CREATED",
2545-
"value_attribute": "on_off"
2546-
}
2547-
],
2548-
"device_ieee": [
2549-
121,
2550-
25,
2551-
2,
2552-
47,
2553-
0,
2554-
188,
2555-
21,
2556-
0
2557-
],
2558-
"endpoint_id": 1,
2559-
"available": false,
2560-
"group_id": null
2561-
},
2562-
"state": {
2563-
"class_name": "Switch",
2564-
"state": false,
2565-
"available": false
2566-
}
2567-
},
25682520
{
25692521
"info_object": {
25702522
"fallback_name": null,

tests/test_binary_sensor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ async def test_quirks_binary_sensor_attr_converter(zha_gateway: Gateway) -> None
223223
SIG_EP_INPUT: [general.Basic.cluster_id, general.OnOff.cluster_id],
224224
SIG_EP_OUTPUT: [],
225225
SIG_EP_TYPE: zha.DeviceType.SIMPLE_SENSOR,
226+
SIG_EP_PROFILE: zha.PROFILE_ID,
226227
}
227228
},
228229
manufacturer="manufacturer",

tests/test_cluster_handlers.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,14 @@ async def test_cluster_no_ep_attribute(
10771077
zha_gateway,
10781078
create_mock_zigpy_device(
10791079
zha_gateway,
1080-
{1: {SIG_EP_INPUT: [0x042E], SIG_EP_OUTPUT: [], SIG_EP_TYPE: 0x1234}},
1080+
{
1081+
1: {
1082+
SIG_EP_INPUT: [0x042E],
1083+
SIG_EP_OUTPUT: [],
1084+
SIG_EP_TYPE: 0x1234,
1085+
SIG_EP_PROFILE: zigpy.profiles.zha.PROFILE_ID,
1086+
}
1087+
},
10811088
),
10821089
)
10831090

@@ -1103,7 +1110,8 @@ class TestZigbeeClusterHandler(ClusterHandler):
11031110
AttrReportConfig(attr="current_y", config=(1, 60, 4)),
11041111
)
11051112

1106-
mock_ep = mock.AsyncMock(spec_set=zigpy.endpoint.Endpoint)
1113+
mock_ep = mock.AsyncMock()
1114+
mock_ep.profile_id = zigpy.profiles.zha.PROFILE_ID
11071115
mock_ep.device.zdo = AsyncMock()
11081116

11091117
cluster = zigpy.zcl.clusters.lighting.Color(mock_ep)
@@ -1150,6 +1158,7 @@ class TestZigbeeClusterHandler(ClusterHandler):
11501158

11511159
mock_device = mock.AsyncMock(spec_set=zigpy.device.Device)
11521160
zigpy_ep = zigpy.endpoint.Endpoint(mock_device, endpoint_id=1)
1161+
zigpy_ep.profile_id = zigpy.profiles.zha.PROFILE_ID
11531162

11541163
cluster = zigpy_ep.add_input_cluster(zigpy.zcl.clusters.lighting.Color.cluster_id)
11551164
cluster.configure_reporting_multiple = AsyncMock(
@@ -1194,6 +1203,7 @@ class TestZigbeeClusterHandler(ColorClusterHandler):
11941203

11951204
mock_device = mock.AsyncMock(spec_set=zigpy.device.Device)
11961205
zigpy_ep = zigpy.endpoint.Endpoint(mock_device, endpoint_id=1)
1206+
zigpy_ep.profile_id = zigpy.profiles.zha.PROFILE_ID
11971207

11981208
cluster = zigpy_ep.add_input_cluster(zigpy.zcl.clusters.lighting.Color.cluster_id)
11991209
cluster.configure_reporting_multiple = AsyncMock(
@@ -1233,6 +1243,7 @@ class TestZigbeeClusterHandler(ColorClusterHandler):
12331243

12341244
mock_device = mock.AsyncMock(spec_set=zigpy.device.Device)
12351245
zigpy_ep = zigpy.endpoint.Endpoint(mock_device, endpoint_id=1)
1246+
zigpy_ep.profile_id = zigpy.profiles.zha.PROFILE_ID
12361247

12371248
cluster = zigpy_ep.add_input_cluster(zigpy.zcl.clusters.lighting.Color.cluster_id)
12381249
cluster.configure_reporting_multiple = AsyncMock(

tests/test_device.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from tests.common import (
2020
SIG_EP_INPUT,
2121
SIG_EP_OUTPUT,
22+
SIG_EP_PROFILE,
2223
SIG_EP_TYPE,
2324
create_mock_zigpy_device,
2425
get_entity,
@@ -58,6 +59,7 @@ def zigpy_device(
5859
SIG_EP_INPUT: in_clusters,
5960
SIG_EP_OUTPUT: [],
6061
SIG_EP_TYPE: zigpy.profiles.zha.DeviceType.ON_OFF_SWITCH,
62+
SIG_EP_PROFILE: zigpy.profiles.zha.PROFILE_ID,
6163
}
6264
}
6365
return create_mock_zigpy_device(zha_gateway, endpoints, **kwargs)
@@ -74,6 +76,7 @@ def zigpy_device_mains(zha_gateway: Gateway, with_basic_cluster_handler: bool =
7476
SIG_EP_INPUT: in_clusters,
7577
SIG_EP_OUTPUT: [],
7678
SIG_EP_TYPE: zigpy.profiles.zha.DeviceType.ON_OFF_SWITCH,
79+
SIG_EP_PROFILE: zigpy.profiles.zha.PROFILE_ID,
7780
}
7881
}
7982
return create_mock_zigpy_device(

tests/test_discover.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ async def test_quirks_v2_entity_discovery(
320320
zigpy.zcl.clusters.general.Scenes.cluster_id,
321321
],
322322
SIG_EP_TYPE: zigpy.profiles.zha.DeviceType.NON_COLOR_CONTROLLER,
323+
SIG_EP_PROFILE: zigpy.profiles.zha.PROFILE_ID,
323324
}
324325
},
325326
ieee="01:2d:6f:00:0a:90:69:e8",
@@ -440,6 +441,7 @@ class FakeXiaomiAqaraDriverE1(XiaomiAqaraDriverE1):
440441
zigpy.zcl.clusters.general.Ota.cluster_id,
441442
XiaomiAqaraDriverE1.cluster_id,
442443
],
444+
SIG_EP_PROFILE: zigpy.profiles.zha.PROFILE_ID,
443445
}
444446
},
445447
ieee="01:2d:6f:00:0a:90:69:e8",
@@ -522,6 +524,7 @@ def _get_test_device(
522524
zigpy.zcl.clusters.general.Scenes.cluster_id,
523525
],
524526
SIG_EP_TYPE: zigpy.profiles.zha.DeviceType.NON_COLOR_CONTROLLER,
527+
SIG_EP_PROFILE: zigpy.profiles.zha.PROFILE_ID,
525528
}
526529
},
527530
ieee="01:2d:6f:00:0a:90:69:e8",

tests/test_select.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ async def test_on_off_select_attribute_report_v2(
175175
],
176176
SIG_EP_OUTPUT: [],
177177
SIG_EP_TYPE: zha.DeviceType.OCCUPANCY_SENSOR,
178+
SIG_EP_PROFILE: zha.PROFILE_ID,
178179
}
179180
},
180181
manufacturer="Fake_Manufacturer",

tests/test_sensor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,7 @@ async def zigpy_device_timestamp_sensor_v2_mock(
13191319
],
13201320
SIG_EP_OUTPUT: [],
13211321
SIG_EP_TYPE: zigpy.profiles.zha.DeviceType.ON_OFF_SWITCH,
1322+
SIG_EP_PROFILE: zigpy.profiles.zha.PROFILE_ID,
13221323
}
13231324
},
13241325
manufacturer="Fake_Timestamp_sensor",
@@ -1420,6 +1421,7 @@ async def zigpy_device_aqara_sensor_v2_mock(
14201421
],
14211422
SIG_EP_OUTPUT: [],
14221423
SIG_EP_TYPE: zigpy.profiles.zha.DeviceType.OCCUPANCY_SENSOR,
1424+
SIG_EP_PROFILE: zigpy.profiles.zha.PROFILE_ID,
14231425
}
14241426
},
14251427
manufacturer="Fake_Manufacturer_sensor",
@@ -1663,6 +1665,7 @@ async def zigpy_device_danfoss_thermostat_mock(
16631665
],
16641666
SIG_EP_OUTPUT: [general.Basic.cluster_id, general.Ota.cluster_id],
16651667
SIG_EP_TYPE: zigpy.profiles.zha.DeviceType.THERMOSTAT,
1668+
SIG_EP_PROFILE: zigpy.profiles.zha.PROFILE_ID,
16661669
}
16671670
},
16681671
manufacturer="Danfoss",
@@ -1717,6 +1720,7 @@ async def test_quirks_sensor_attr_converter(zha_gateway: Gateway) -> None:
17171720
],
17181721
SIG_EP_OUTPUT: [],
17191722
SIG_EP_TYPE: zha.DeviceType.SIMPLE_SENSOR,
1723+
SIG_EP_PROFILE: zigpy.profiles.zha.PROFILE_ID,
17201724
}
17211725
},
17221726
manufacturer="manufacturer",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy