From 008a02943313bf4830d0a47b58a64ec5b7602468 Mon Sep 17 00:00:00 2001 From: Marc Dirix Date: Thu, 28 Aug 2025 13:36:07 +0200 Subject: [PATCH 1/7] allow get_state request for non-data NodeFeatures --- plugwise_usb/nodes/circle.py | 3 ++- plugwise_usb/nodes/node.py | 4 ++-- plugwise_usb/nodes/scan.py | 3 ++- plugwise_usb/nodes/sed.py | 3 ++- plugwise_usb/nodes/sense.py | 3 ++- plugwise_usb/nodes/switch.py | 3 ++- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/plugwise_usb/nodes/circle.py b/plugwise_usb/nodes/circle.py index 3c548e449..a5fd912ed 100644 --- a/plugwise_usb/nodes/circle.py +++ b/plugwise_usb/nodes/circle.py @@ -1294,7 +1294,8 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any ) case _: state_result = await super().get_state((feature,)) - states[feature] = state_result[feature] + if feature in state_result: + states[feature] = state_result[feature] if NodeFeature.AVAILABLE not in states: states[NodeFeature.AVAILABLE] = self.available_state diff --git a/plugwise_usb/nodes/node.py b/plugwise_usb/nodes/node.py index 5c223ffa0..cb3ce660a 100644 --- a/plugwise_usb/nodes/node.py +++ b/plugwise_usb/nodes/node.py @@ -633,9 +633,9 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any case NodeFeature.PING: states[NodeFeature.PING] = await self.ping_update() case _: - raise NodeError( + _LOGGER.debug( f"Update of feature '{feature.name}' is " - + f"not supported for {self.mac}" + + f"does not return any data {self.mac}" ) return states diff --git a/plugwise_usb/nodes/scan.py b/plugwise_usb/nodes/scan.py index fc3e84c46..8e5cc9752 100644 --- a/plugwise_usb/nodes/scan.py +++ b/plugwise_usb/nodes/scan.py @@ -529,7 +529,8 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any states[NodeFeature.MOTION_CONFIG] = self._motion_config case _: state_result = await super().get_state((feature,)) - states[feature] = state_result[feature] + if feature in state_result: + states[feature] = state_result[feature] if NodeFeature.AVAILABLE not in states: states[NodeFeature.AVAILABLE] = self.available_state diff --git a/plugwise_usb/nodes/sed.py b/plugwise_usb/nodes/sed.py index acf3b81cc..d31e3e98d 100644 --- a/plugwise_usb/nodes/sed.py +++ b/plugwise_usb/nodes/sed.py @@ -647,6 +647,7 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any states[NodeFeature.BATTERY] = self._battery_config case _: state_result = await super().get_state((feature,)) - states[feature] = state_result[feature] + if feature in state_result: + states[feature] = state_result[feature] return states diff --git a/plugwise_usb/nodes/sense.py b/plugwise_usb/nodes/sense.py index 2b61a2c53..a7f7c431b 100644 --- a/plugwise_usb/nodes/sense.py +++ b/plugwise_usb/nodes/sense.py @@ -165,7 +165,8 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any states[NodeFeature.SENSE] = self._sense_statistics case _: state_result = await super().get_state((feature,)) - states[feature] = state_result[feature] + if feature in state_result: + states[feature] = state_result[feature] if NodeFeature.AVAILABLE not in states: states[NodeFeature.AVAILABLE] = self.available_state diff --git a/plugwise_usb/nodes/switch.py b/plugwise_usb/nodes/switch.py index 12489f722..ce0265b0b 100644 --- a/plugwise_usb/nodes/switch.py +++ b/plugwise_usb/nodes/switch.py @@ -154,7 +154,8 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any states[NodeFeature.SWITCH] = self._switch case _: state_result = await super().get_state((feature,)) - states[feature] = state_result[feature] + if feature in state_result: + states[feature] = state_result[feature] if NodeFeature.AVAILABLE not in states: states[NodeFeature.AVAILABLE] = self.available_state From 8b037643232bf84565ca55586fab9c8894a4beca Mon Sep 17 00:00:00 2001 From: Marc Dirix Date: Thu, 28 Aug 2025 13:36:07 +0200 Subject: [PATCH 2/7] allow get_state request for non-data NodeFeatures --- plugwise_usb/nodes/circle.py | 3 ++- plugwise_usb/nodes/node.py | 4 ++-- plugwise_usb/nodes/scan.py | 3 ++- plugwise_usb/nodes/sed.py | 3 ++- plugwise_usb/nodes/sense.py | 3 ++- plugwise_usb/nodes/switch.py | 3 ++- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/plugwise_usb/nodes/circle.py b/plugwise_usb/nodes/circle.py index 3c548e449..a5fd912ed 100644 --- a/plugwise_usb/nodes/circle.py +++ b/plugwise_usb/nodes/circle.py @@ -1294,7 +1294,8 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any ) case _: state_result = await super().get_state((feature,)) - states[feature] = state_result[feature] + if feature in state_result: + states[feature] = state_result[feature] if NodeFeature.AVAILABLE not in states: states[NodeFeature.AVAILABLE] = self.available_state diff --git a/plugwise_usb/nodes/node.py b/plugwise_usb/nodes/node.py index 5c223ffa0..cb3ce660a 100644 --- a/plugwise_usb/nodes/node.py +++ b/plugwise_usb/nodes/node.py @@ -633,9 +633,9 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any case NodeFeature.PING: states[NodeFeature.PING] = await self.ping_update() case _: - raise NodeError( + _LOGGER.debug( f"Update of feature '{feature.name}' is " - + f"not supported for {self.mac}" + + f"does not return any data {self.mac}" ) return states diff --git a/plugwise_usb/nodes/scan.py b/plugwise_usb/nodes/scan.py index 248d6b6c9..aec4ed6a3 100644 --- a/plugwise_usb/nodes/scan.py +++ b/plugwise_usb/nodes/scan.py @@ -545,7 +545,8 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any states[NodeFeature.MOTION_CONFIG] = self._motion_config case _: state_result = await super().get_state((feature,)) - states[feature] = state_result[feature] + if feature in state_result: + states[feature] = state_result[feature] if NodeFeature.AVAILABLE not in states: states[NodeFeature.AVAILABLE] = self.available_state diff --git a/plugwise_usb/nodes/sed.py b/plugwise_usb/nodes/sed.py index c980ea533..b9b049c12 100644 --- a/plugwise_usb/nodes/sed.py +++ b/plugwise_usb/nodes/sed.py @@ -632,6 +632,7 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any states[NodeFeature.BATTERY] = self._battery_config case _: state_result = await super().get_state((feature,)) - states[feature] = state_result[feature] + if feature in state_result: + states[feature] = state_result[feature] return states diff --git a/plugwise_usb/nodes/sense.py b/plugwise_usb/nodes/sense.py index 2b61a2c53..a7f7c431b 100644 --- a/plugwise_usb/nodes/sense.py +++ b/plugwise_usb/nodes/sense.py @@ -165,7 +165,8 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any states[NodeFeature.SENSE] = self._sense_statistics case _: state_result = await super().get_state((feature,)) - states[feature] = state_result[feature] + if feature in state_result: + states[feature] = state_result[feature] if NodeFeature.AVAILABLE not in states: states[NodeFeature.AVAILABLE] = self.available_state diff --git a/plugwise_usb/nodes/switch.py b/plugwise_usb/nodes/switch.py index 12489f722..ce0265b0b 100644 --- a/plugwise_usb/nodes/switch.py +++ b/plugwise_usb/nodes/switch.py @@ -154,7 +154,8 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any states[NodeFeature.SWITCH] = self._switch case _: state_result = await super().get_state((feature,)) - states[feature] = state_result[feature] + if feature in state_result: + states[feature] = state_result[feature] if NodeFeature.AVAILABLE not in states: states[NodeFeature.AVAILABLE] = self.available_state From a0091e68dfbef991cad1b010c7963703729c549c Mon Sep 17 00:00:00 2001 From: Marc Dirix Date: Thu, 28 Aug 2025 14:11:34 +0200 Subject: [PATCH 3/7] fix debug note --- plugwise_usb/nodes/node.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugwise_usb/nodes/node.py b/plugwise_usb/nodes/node.py index cb3ce660a..a41611e1f 100644 --- a/plugwise_usb/nodes/node.py +++ b/plugwise_usb/nodes/node.py @@ -634,8 +634,9 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any states[NodeFeature.PING] = await self.ping_update() case _: _LOGGER.debug( - f"Update of feature '{feature.name}' is " - + f"does not return any data {self.mac}" + "Update of feature '%s' does not return any data for %s", + feature.name, + self.mac, ) return states From 4714f80bb605c4241a79757867652e4eeb74cdba Mon Sep 17 00:00:00 2001 From: Marc Dirix Date: Thu, 28 Aug 2025 14:16:21 +0200 Subject: [PATCH 4/7] CR: Nitpick language --- plugwise_usb/nodes/scan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugwise_usb/nodes/scan.py b/plugwise_usb/nodes/scan.py index aec4ed6a3..3607f870a 100644 --- a/plugwise_usb/nodes/scan.py +++ b/plugwise_usb/nodes/scan.py @@ -524,7 +524,7 @@ async def _scan_calibrate_light(self) -> bool: ) async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any]: - """Update latest state for given feature.""" + """Update latest state for given features.""" states: dict[NodeFeature, Any] = {} for feature in features: _LOGGER.debug( From 84f2e0bf72039710a6e06d0df70d5886a026cb20 Mon Sep 17 00:00:00 2001 From: Marc Dirix Date: Thu, 28 Aug 2025 14:18:24 +0200 Subject: [PATCH 5/7] CR: fix ruff --- plugwise_usb/nodes/circle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugwise_usb/nodes/circle.py b/plugwise_usb/nodes/circle.py index a5fd912ed..ae4e095ac 100644 --- a/plugwise_usb/nodes/circle.py +++ b/plugwise_usb/nodes/circle.py @@ -1243,7 +1243,7 @@ def _correct_power_pulses(self, pulses: int, offset: int) -> float: return 0.0 @raise_not_loaded - async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any]: + async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any]: # noqa: PLR0912 """Update latest state for given feature.""" states: dict[NodeFeature, Any] = {} if not self._available and not await self.is_online(): From 80f00e5667d44433f954386ec77441c0e5522ac4 Mon Sep 17 00:00:00 2001 From: Marc Dirix Date: Thu, 28 Aug 2025 15:00:41 +0200 Subject: [PATCH 6/7] testpypi release 0.44.13a1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c8c5cd979..12a083014 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "plugwise_usb" -version = "0.44.13a0" +version = "0.44.13a1" license = "MIT" keywords = ["home", "automation", "plugwise", "module", "usb"] classifiers = [ From da4d303d9fe176522b5f9e3a330598d73f0af85a Mon Sep 17 00:00:00 2001 From: Marc Dirix Date: Fri, 29 Aug 2025 11:51:46 +0200 Subject: [PATCH 7/7] update changelog and dump to 0.44.13 --- CHANGELOG.md | 3 ++- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aa3b83f1..2522a2198 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ # Changelog -## ongoing +## v0.44.13 - 2025-08-29 - PR [327](https://github.com/plugwise/python-plugwise-usb/pull/327): Improve code quality according to SonarCloud, simplify sed awake timer +- PR [328](https://github.com/plugwise/python-plugwise-usb/pull/328): allow get_state request for non-data NodeFeatures ## v0.44.12 - 2025-08-24 diff --git a/pyproject.toml b/pyproject.toml index 12a083014..0999c77ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "plugwise_usb" -version = "0.44.13a1" +version = "0.44.13" license = "MIT" keywords = ["home", "automation", "plugwise", "module", "usb"] classifiers = [