Skip to content

Commit 820df8b

Browse files
committed
CR: verify _start_node_discover is properly set before calling
1 parent 3bd2fa9 commit 820df8b

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

plugwise_usb/network/registry.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,13 @@ async def update_missing_registrations_circleplus(self) -> None:
197197
continue
198198
_maintenance_registry.append(mac)
199199
if self.update_network_registration(mac):
200-
await self._start_node_discover(mac, None, False)
200+
if self._start_node_discover is not None:
201+
await self._start_node_discover(mac, None, False)
202+
else:
203+
_LOGGER.debug(
204+
"No start_node_discover callback set; skipping for %s", mac
205+
)
206+
201207
await sleep(self._registration_scan_delay)
202208
_LOGGER.debug("CirclePlus registry scan finished")
203209
self._scan_completed = True
@@ -218,7 +224,12 @@ async def load_registrations_from_cache(self) -> None:
218224
)
219225
for mac, nodetype in self._network_cache.nodetypes.items():
220226
self.update_network_registration(mac)
221-
await self._start_node_discover(mac, nodetype, True)
227+
if self._start_node_discover is not None:
228+
await self._start_node_discover(mac, nodetype, True)
229+
else:
230+
_LOGGER.debug(
231+
"No start_node_discover callback set; skipping for %s", mac
232+
)
222233
await sleep(0.1)
223234
_LOGGER.info("Cache network registration discovery finished")
224235
if self._scan_completed_callback is not None:
@@ -245,7 +256,12 @@ async def register_node(self, mac: str) -> None:
245256
except StickError as exc:
246257
raise NodeError(f"{exc}") from exc
247258
if self.update_network_registration(mac):
248-
await self._start_node_discover(mac, None, False)
259+
if self._start_node_discover is not None:
260+
await self._start_node_discover(mac, None, False)
261+
else:
262+
_LOGGER.debug(
263+
"No start_node_discover callback set; skipping for %s", mac
264+
)
249265

250266
async def unregister_node(self, mac: str) -> None:
251267
"""Unregister node from current Plugwise network."""

0 commit comments

Comments
 (0)