Skip to content

Commit 3e6a036

Browse files
authored
Fix startup error due to None node descriptor (#161)
1 parent 5f85872 commit 3e6a036

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

tests/test_application.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,10 +621,9 @@ async def test_restore_neighbours(app):
621621
device_2.nwk = 0x2222
622622
nei_2 = zigpy.neighbor.Neighbor(sentinel.nei_2, device_2)
623623

624-
# invalid node descriptor
625-
desc_3 = zdo_t.NodeDescriptor()
624+
# Missing node descriptor
626625
device_3 = MagicMock()
627-
device_3.node_desc = desc_3
626+
device_3.node_desc = None
628627
device_3.ieee = sentinel.ieee_3
629628
device_3.nwk = 0x3333
630629
nei_3 = zigpy.neighbor.Neighbor(sentinel.nei_3, device_3)

zigpy_deconz/zigbee/application.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,18 +345,20 @@ async def restore_neighbours(self) -> None:
345345
for device in devices:
346346
if device is None:
347347
continue
348+
descr = device.node_desc
348349
LOGGER.debug(
349350
"device: 0x%04x - %s %s, FFD=%s, Rx_on_when_idle=%s",
350351
device.nwk,
351352
device.manufacturer,
352353
device.model,
353-
device.node_desc.is_full_function_device,
354-
device.node_desc.is_receiver_on_when_idle,
354+
descr.is_full_function_device if descr is not None else None,
355+
descr.is_receiver_on_when_idle if descr is not None else None,
355356
)
356-
descr = device.node_desc
357-
if not descr.is_valid:
358-
continue
359-
if descr.is_full_function_device or descr.is_receiver_on_when_idle:
357+
if (
358+
descr is None
359+
or descr.is_full_function_device
360+
or descr.is_receiver_on_when_idle
361+
):
360362
continue
361363
LOGGER.debug(
362364
"Restoring %s/0x%04x device as direct child",

0 commit comments

Comments
 (0)