Skip to content

Commit

Permalink
Fix parsing XBee ZDO data (#2608)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shulyaka authored Sep 29, 2023
1 parent 7385465 commit 74b9f04
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_xbee.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions zhaquirks/xbee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 74b9f04

Please sign in to comment.