Skip to content

Commit 97bc022

Browse files
committed
Optimize: change function-name to update_node_registration
1 parent c23bd72 commit 97bc022

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

plugwise_usb/network/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ async def node_rejoin_message(self, response: PlugwiseResponse) -> bool:
273273
)
274274
mac = response.mac_decoded
275275
if (address := self._register.network_address(mac)) is None:
276-
if (address := self._register.register_rejoined_node(mac)) is None:
276+
if (address := self._register.update_node_registration(mac)) is None:
277277
raise NodeError(f"Failed to obtain address for node {mac}")
278278

279279
if self._nodes.get(mac) is None:

plugwise_usb/network/registry.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,10 @@ async def register_node(self, mac: str) -> int:
259259
except MessageError as exc:
260260
raise MessageError(f"Failed to register Node with {mac}") from exc
261261

262-
self.update_network_registration(self._first_free_address, mac, None)
263-
self._first_free_address += 1
264-
return self._first_free_address - 1
265-
266-
async def register_rejoined_node(self, mac: str) -> int:
267-
"""Re-register rejoined node to Plugwise network and return network address."""
268-
if not validate_mac(mac):
269-
raise NodeError(f"MAC '{mac}' invalid")
262+
return self.update_node_registration(mac)
270263

264+
async def update_node_registration(self, mac: str) -> int:
265+
"""Register (re)joined node to Plugwise network and return network address."""
271266
self.update_network_registration(self._first_free_address, mac, None)
272267
self._first_free_address += 1
273268
return self._first_free_address - 1

0 commit comments

Comments
 (0)