@@ -234,7 +234,7 @@ async def set_schedule_state(
234234
235235 async def set_switch_state (
236236 self , appl_id : str , members : list [str ] | None , model : str , state : str
237- ) -> None :
237+ ) -> bool :
238238 """Set the given state of the relevant switch.
239239
240240 For individual switches, sets the state directly.
@@ -269,7 +269,7 @@ async def set_switch_state(
269269 "</appliances>"
270270 )
271271 await self .call_request (APPLIANCES , method = "post" , data = data )
272- return
272+ return True
273273
274274 # Handle group of switches
275275 data = f"<{ switch .func_type } ><state>{ state } </state></{ switch .func_type } >"
@@ -280,26 +280,26 @@ async def set_switch_state(
280280
281281 # Handle individual relay switches
282282 uri = f"{ APPLIANCES } ;id={ appl_id } /relay"
283- if model == "relay" :
284- locator = (
285- f'appliance[@id="{ appl_id } "]/{ switch .actuator } /{ switch .func_type } /lock'
286- )
283+ if model == "relay" and self .gw_entities [appl_id ]["switches" ]["lock" ]:
287284 # Don't bother switching a relay when the corresponding lock-state is true
288- if self ._appliances .find (locator ).text == "true" :
289- raise PlugwiseError ("Plugwise: the locked Relay was not switched." )
285+ return False
290286
291287 await self .call_request (uri , method = "put" , data = data )
288+ return True
292289
293290 async def _set_groupswitch_member_state (
294291 self , data : str , members : list [str ], state : str , switch : Munch
295- ) -> None :
292+ ) -> bool :
296293 """Helper-function for set_switch_state().
297294
298295 Set the given State of the relevant Switch (relay) within a group of members.
299296 """
300297 for member in members :
301- uri = f"{ APPLIANCES } ;id={ member } /relay"
302- await self .call_request (uri , method = "put" , data = data )
298+ if not self .gw_entities [member ]["switches" ]["lock" ]:
299+ uri = f"{ APPLIANCES } ;id={ member } /relay"
300+ await self .call_request (uri , method = "put" , data = data )
301+
302+ return True
303303
304304 async def set_temperature (self , _ : str , items : dict [str , float ]) -> None :
305305 """Set the given Temperature on the relevant Thermostat."""
0 commit comments