Skip to content

Commit b7176ce

Browse files
authored
Merge pull request #328 from plugwise/mdi_nodefeature
allow get_state request for non-data NodeFeatures
2 parents f9ea8f7 + da4d303 commit b7176ce

File tree

8 files changed

+19
-12
lines changed

8 files changed

+19
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Changelog
22

3-
## ongoing
3+
## v0.44.13 - 2025-08-29
44

55
- PR [327](https://github.com/plugwise/python-plugwise-usb/pull/327): Improve code quality according to SonarCloud, simplify sed awake timer
6+
- PR [328](https://github.com/plugwise/python-plugwise-usb/pull/328): allow get_state request for non-data NodeFeatures
67

78
## v0.44.12 - 2025-08-24
89

plugwise_usb/nodes/circle.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ def _correct_power_pulses(self, pulses: int, offset: int) -> float:
12431243
return 0.0
12441244

12451245
@raise_not_loaded
1246-
async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any]:
1246+
async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any]: # noqa: PLR0912
12471247
"""Update latest state for given feature."""
12481248
states: dict[NodeFeature, Any] = {}
12491249
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
12941294
)
12951295
case _:
12961296
state_result = await super().get_state((feature,))
1297-
states[feature] = state_result[feature]
1297+
if feature in state_result:
1298+
states[feature] = state_result[feature]
12981299

12991300
if NodeFeature.AVAILABLE not in states:
13001301
states[NodeFeature.AVAILABLE] = self.available_state

plugwise_usb/nodes/node.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,10 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
633633
case NodeFeature.PING:
634634
states[NodeFeature.PING] = await self.ping_update()
635635
case _:
636-
raise NodeError(
637-
f"Update of feature '{feature.name}' is "
638-
+ f"not supported for {self.mac}"
636+
_LOGGER.debug(
637+
"Update of feature '%s' does not return any data for %s",
638+
feature.name,
639+
self.mac,
639640
)
640641

641642
return states

plugwise_usb/nodes/scan.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ async def _scan_calibrate_light(self) -> bool:
524524
)
525525

526526
async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any]:
527-
"""Update latest state for given feature."""
527+
"""Update latest state for given features."""
528528
states: dict[NodeFeature, Any] = {}
529529
for feature in features:
530530
_LOGGER.debug(
@@ -545,7 +545,8 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
545545
states[NodeFeature.MOTION_CONFIG] = self._motion_config
546546
case _:
547547
state_result = await super().get_state((feature,))
548-
states[feature] = state_result[feature]
548+
if feature in state_result:
549+
states[feature] = state_result[feature]
549550

550551
if NodeFeature.AVAILABLE not in states:
551552
states[NodeFeature.AVAILABLE] = self.available_state

plugwise_usb/nodes/sed.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
632632
states[NodeFeature.BATTERY] = self._battery_config
633633
case _:
634634
state_result = await super().get_state((feature,))
635-
states[feature] = state_result[feature]
635+
if feature in state_result:
636+
states[feature] = state_result[feature]
636637

637638
return states

plugwise_usb/nodes/sense.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
165165
states[NodeFeature.SENSE] = self._sense_statistics
166166
case _:
167167
state_result = await super().get_state((feature,))
168-
states[feature] = state_result[feature]
168+
if feature in state_result:
169+
states[feature] = state_result[feature]
169170

170171
if NodeFeature.AVAILABLE not in states:
171172
states[NodeFeature.AVAILABLE] = self.available_state

plugwise_usb/nodes/switch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
154154
states[NodeFeature.SWITCH] = self._switch
155155
case _:
156156
state_result = await super().get_state((feature,))
157-
states[feature] = state_result[feature]
157+
if feature in state_result:
158+
states[feature] = state_result[feature]
158159

159160
if NodeFeature.AVAILABLE not in states:
160161
states[NodeFeature.AVAILABLE] = self.available_state

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "plugwise_usb"
7-
version = "0.44.13a0"
7+
version = "0.44.13"
88
license = "MIT"
99
keywords = ["home", "automation", "plugwise", "module", "usb"]
1010
classifiers = [

0 commit comments

Comments
 (0)