Skip to content

Commit 870fdf2

Browse files
committed
Remove double code, update docstring
1 parent 9abd9df commit 870fdf2

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

plugwise_usb/messages/requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def serialize(self) -> bytes:
410410

411411

412412
class PlugwiseRequestWithStickResponse(PlugwiseRequest):
413-
"""Base class of a plugwise request with a NodeAckResponse."""
413+
"""Base class of a plugwise request resulting in a StickResponse."""
414414

415415
async def send(self, suppress_node_errors: bool = False) -> StickResponse | None:
416416
"""Send request."""

plugwise_usb/network/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from ..connection import StickController
1515
from ..constants import UTF8
1616
from ..exceptions import CacheError, MessageError, NodeError, StickError, StickTimeout
17-
from ..helpers.util import validate_mac
1817
from ..messages.requests import CirclePlusAllowJoiningRequest, NodePingRequest
1918
from ..messages.responses import (
2019
NODE_AWAKE_RESPONSE_ID,
@@ -149,8 +148,6 @@ def registry(self) -> dict[int, tuple[str, NodeType | None]]:
149148

150149
async def register_node(self, mac: str) -> bool:
151150
"""Register node to Plugwise network."""
152-
if not validate_mac(mac):
153-
raise NodeError(f"MAC '{mac}' invalid")
154151
address = await self._register.register_node(mac)
155152
return await self._discover_node(address, mac, None)
156153

plugwise_usb/network/registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ async def save_registry_to_cache(self) -> None:
246246
async def register_node(self, mac: str) -> int:
247247
"""Register node to Plugwise network and return network address."""
248248
if not validate_mac(mac):
249-
raise NodeError(f"Invalid mac '{mac}' to register")
249+
raise NodeError(f"MAC '{mac}' invalid")
250250

251251
request = NodeAddRequest(self._send_to_controller, bytes(mac, UTF8), True)
252252
response = await request.send()
@@ -259,7 +259,7 @@ async def register_node(self, mac: str) -> int:
259259
async def unregister_node(self, mac: str) -> None:
260260
"""Unregister node from current Plugwise network."""
261261
if not validate_mac(mac):
262-
raise NodeError(f"Invalid mac '{mac}' to unregister")
262+
raise NodeError(f"MAC '{mac}' invalid")
263263

264264
mac_registered = False
265265
for registration in self._registry.values():

0 commit comments

Comments
 (0)