Skip to content

Commit 614bf4a

Browse files
committed
Fix logic for node_join_available_message() and node_rejoin_message()
1 parent 7ba67bb commit 614bf4a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

plugwise_usb/network/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,15 @@ async def node_join_available_message(self, response: PlugwiseResponse) -> bool:
257257
mac = response.mac_decoded
258258
_LOGGER.debug("node_join_available_message | adding available Node %s", mac)
259259
try:
260-
await self.register_node(mac)
260+
result = await self.register_node(mac)
261261
except NodeError as exc:
262262
raise NodeError(f"Unable to add Node ({mac}): {exc}") from exc
263263

264-
await self._notify_node_event_subscribers(NodeEvent.JOIN, mac)
265-
return True
264+
if result:
265+
await self._notify_node_event_subscribers(NodeEvent.JOIN, mac)
266+
return True
267+
268+
return False
266269

267270
async def node_rejoin_message(self, response: PlugwiseResponse) -> bool:
268271
"""Handle NodeRejoinResponse messages."""
@@ -287,6 +290,8 @@ async def node_rejoin_message(self, response: PlugwiseResponse) -> bool:
287290
else:
288291
_LOGGER.debug("duplicate awake discovery for %s", mac)
289292
return True
293+
294+
return False
290295

291296
def _unsubscribe_to_protocol_events(self) -> None:
292297
"""Unsubscribe to events from protocol."""

0 commit comments

Comments
 (0)