Skip to content

Commit 8b03764

Browse files
committed
allow get_state request for non-data NodeFeatures
1 parent f9ea8f7 commit 8b03764

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
@@ -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

0 commit comments

Comments
 (0)