Skip to content

Commit 008a029

Browse files
committed
allow get_state request for non-data NodeFeatures
1 parent 6be2724 commit 008a029

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,9 @@ 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(
636+
_LOGGER.debug(
637637
f"Update of feature '{feature.name}' is "
638-
+ f"not supported for {self.mac}"
638+
+ f"does not return any data {self.mac}"
639639
)
640640

641641
return states

plugwise_usb/nodes/scan.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,8 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
529529
states[NodeFeature.MOTION_CONFIG] = self._motion_config
530530
case _:
531531
state_result = await super().get_state((feature,))
532-
states[feature] = state_result[feature]
532+
if feature in state_result:
533+
states[feature] = state_result[feature]
533534

534535
if NodeFeature.AVAILABLE not in states:
535536
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
@@ -647,6 +647,7 @@ async def get_state(self, features: tuple[NodeFeature]) -> dict[NodeFeature, Any
647647
states[NodeFeature.BATTERY] = self._battery_config
648648
case _:
649649
state_result = await super().get_state((feature,))
650-
states[feature] = state_result[feature]
650+
if feature in state_result:
651+
states[feature] = state_result[feature]
651652

652653
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

0 commit comments

Comments
 (0)