From 74b9f043a996da6baca722d1e191d842a31ae198 Mon Sep 17 00:00:00 2001 From: Denis Shulyaka Date: Fri, 29 Sep 2023 08:41:16 +0300 Subject: [PATCH] Fix parsing XBee ZDO data (#2608) --- tests/test_xbee.py | 18 ++++++++++++++++++ zhaquirks/xbee/__init__.py | 2 ++ 2 files changed, 20 insertions(+) diff --git a/tests/test_xbee.py b/tests/test_xbee.py index 24b21e394e..91b986e60b 100644 --- a/tests/test_xbee.py +++ b/tests/test_xbee.py @@ -641,3 +641,21 @@ def mock_at_response(*args, **kwargs): assert 33.33333 < analog_listeners[0].attribute_updates[0][1] < 33.33334 assert 66.66666 < analog_listeners[2].attribute_updates[0][1] < 66.66667 assert analog_listeners[4].attribute_updates[0] == (0x0055, 3.305) + + +@mock.patch("zigpy.zdo.ZDO.handle_ieee_addr_req") +async def test_zdo(handle_mgmt_lqi_resp, zigpy_device_from_quirk): + """Test receiving ZDO data from XBee device.""" + + xbee3_device = zigpy_device_from_quirk(XBee3Sensor) + + # Receive ZDOCmd.IEEE_addr_req + xbee3_device.handle_message(0, 0x0001, 0, 0, b"\x07\x34\x12\x00\x00") + + assert handle_mgmt_lqi_resp.call_count == 1 + assert len(handle_mgmt_lqi_resp.call_args_list[0][0]) == 4 + assert handle_mgmt_lqi_resp.call_args_list[0][0][0].tsn == 0x07 + assert handle_mgmt_lqi_resp.call_args_list[0][0][0].command_id == 0x0001 + assert handle_mgmt_lqi_resp.call_args_list[0][0][1] == 0x1234 + assert handle_mgmt_lqi_resp.call_args_list[0][0][2] == 0 + assert handle_mgmt_lqi_resp.call_args_list[0][0][3] == 0 diff --git a/zhaquirks/xbee/__init__.py b/zhaquirks/xbee/__init__.py index 98068a372e..470d2692f0 100644 --- a/zhaquirks/xbee/__init__.py +++ b/zhaquirks/xbee/__init__.py @@ -629,6 +629,8 @@ def remote_at(self, command, *args, **kwargs): def deserialize(self, endpoint_id, cluster_id, data): """Deserialize.""" + if endpoint_id == 0: + return super().deserialize(endpoint_id, cluster_id, data) tsn = self._application.get_sequence() command_id = 0x0000 hdr = foundation.ZCLHeader.cluster(tsn, command_id)