From 24e41914bae0fd04628e3eef3777389adbd0d915 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sat, 24 May 2025 14:12:08 +0200 Subject: [PATCH 1/3] Implement suggested port-related improvements --- plugwise_usb/__init__.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugwise_usb/__init__.py b/plugwise_usb/__init__.py index c69fce361..be9d4e481 100644 --- a/plugwise_usb/__init__.py +++ b/plugwise_usb/__init__.py @@ -176,10 +176,8 @@ def port(self, port: str) -> None: raise StickError( "Unable to change port while connected. Disconnect first" ) - if self._port is None: - self._port = port - if port != self._port: - self._port = port + + self._port = port @property def accept_join_request(self) -> bool | None: @@ -278,14 +276,14 @@ async def connect(self, port: str | None = None) -> None: f"Already connected to {self._port}, " + "Close existing connection before (re)connect." ) - if port is not None: - self._port = port if self._port is None: raise StickError( "Unable to connect. " + "Path to USB-Stick is not defined, set port property first" ) + + self._port = port await self._controller.connect_to_stick( self._port, ) From f838105d88074058e66a0941010a27a443dbceab Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sat, 24 May 2025 14:13:26 +0200 Subject: [PATCH 2/3] Add missing space --- plugwise_usb/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugwise_usb/__init__.py b/plugwise_usb/__init__.py index be9d4e481..76d625d94 100644 --- a/plugwise_usb/__init__.py +++ b/plugwise_usb/__init__.py @@ -199,7 +199,7 @@ async def set_accept_join_request(self, state: bool) -> bool: if self._network is None or not self._network.is_running: raise StickError( "Cannot accept joining node" - + "without node discovery be activated. Call discover() first." + + " without node discovery be activated. Call discover() first." ) # Observation: joining is only temporarily possible after a HA (re)start or From 8ed5ac5e1093d05327aa87aa207155e231dfdafc Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sat, 24 May 2025 14:34:58 +0200 Subject: [PATCH 3/3] Revert port-related deletion/change --- plugwise_usb/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugwise_usb/__init__.py b/plugwise_usb/__init__.py index 76d625d94..2e37b5be0 100644 --- a/plugwise_usb/__init__.py +++ b/plugwise_usb/__init__.py @@ -277,13 +277,15 @@ async def connect(self, port: str | None = None) -> None: "Close existing connection before (re)connect." ) + if port is not None: + self._port = port + if self._port is None: raise StickError( "Unable to connect. " + "Path to USB-Stick is not defined, set port property first" ) - self._port = port await self._controller.connect_to_stick( self._port, )