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/plugwise_usb/nodes/circle.py b/plugwise_usb/nodes/circle.py index 3c548e449..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(): @@ -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..a41611e1f 100644 --- a/plugwise_usb/nodes/node.py +++ b/plugwise_usb/nodes/node.py @@ -633,9 +633,10 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any case NodeFeature.PING: states[NodeFeature.PING] = await self.ping_update() case _: - raise NodeError( - f"Update of feature '{feature.name}' is " - + f"not supported for {self.mac}" + _LOGGER.debug( + "Update of feature '%s' does not return any data for %s", + feature.name, + self.mac, ) return states diff --git a/plugwise_usb/nodes/scan.py b/plugwise_usb/nodes/scan.py index 248d6b6c9..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( @@ -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 diff --git a/pyproject.toml b/pyproject.toml index c8c5cd979..0999c77ed 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.13" license = "MIT" keywords = ["home", "automation", "plugwise", "module", "usb"] classifiers = [