Skip to content

Commit 07fc53e

Browse files
authored
Handle None node descriptor (#119)
1 parent 93fe805 commit 07fc53e

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

tests/test_application.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,15 +404,20 @@ async def _test_request(
404404
expect_reply=True,
405405
send_success=True,
406406
send_timeout=False,
407-
is_end_device=None,
407+
is_end_device=True,
408+
node_desc=True,
408409
**kwargs
409410
):
410411
seq = 123
411412
nwk = 0x2345
412413
ieee = t.EUI64(b"\x01\x02\x03\x04\x05\x06\x07\x08")
413414
dev = app.add_device(ieee, nwk)
414-
dev.node_desc = mock.MagicMock()
415-
dev.node_desc.is_end_device = is_end_device
415+
416+
if node_desc:
417+
dev.node_desc = mock.MagicMock()
418+
dev.node_desc.is_end_device = is_end_device
419+
else:
420+
dev.node_desc = None
416421

417422
def _mock_command(
418423
cmdname, ieee, nwk, src_ep, dst_ep, cluster, profile, radius, options, data
@@ -445,6 +450,12 @@ async def test_request_with_reply(app):
445450
assert r[0] == 0
446451

447452

453+
@pytest.mark.asyncio
454+
async def test_request_without_node_desc(app):
455+
r = await _test_request(app, expect_reply=True, send_success=True, node_desc=False)
456+
assert r[0] == 0
457+
458+
448459
@pytest.mark.asyncio
449460
async def test_request_send_timeout(app):
450461
r = await _test_request(app, send_timeout=True)
@@ -466,8 +477,7 @@ async def test_request_extended_timeout(app):
466477
assert app._api._command.call_args[0][8] & 0x40 == 0x00
467478
app._api._command.reset_mock()
468479

469-
is_end_device = None
470-
r = await _test_request(app, True, True, is_end_device=is_end_device)
480+
r = await _test_request(app, True, True, node_desc=False)
471481
assert r[0] == xbee_t.TXStatus.SUCCESS
472482
assert app._api._command.call_count == 1
473483
assert app._api._command.call_args[0][8] & 0x40 == 0x40

zigpy_xbee/zigbee/application.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,9 @@ async def request(
222222
LOGGER.debug("Zigbee request tsn #%s: %s", sequence, binascii.hexlify(data))
223223

224224
tx_opts = 0x00
225-
if expect_reply and device.node_desc.is_end_device in (True, None):
225+
if expect_reply and (
226+
device.node_desc is None or device.node_desc.is_end_device
227+
):
226228
tx_opts |= 0x40
227229
send_req = self._api.tx_explicit(
228230
device.ieee,

0 commit comments

Comments
 (0)