@@ -231,14 +231,20 @@ async def set_schedule_state(
231231 async def set_switch_state (
232232 self , appl_id : str , members : list [str ] | None , model : str , state : str
233233 ) -> None :
234- """Set the given State of the relevant Switch."""
234+ """Set the given state of the relevant switch.
235+
236+ For individual switches, sets the state directly.
237+ For group switches, sets the state for each member in the group separately.
238+ For switch-locks, sets the lock state using a different data format.
239+ """
235240 switch = Munch ()
236241 switch .actuator = "actuator_functionalities"
237242 switch .func_type = "relay_functionality"
238243 if self ._stretch_v2 :
239244 switch .actuator = "actuators"
240245 switch .func_type = "relay"
241246
247+ # Handle switch-lock
242248 if model == "lock" :
243249 state = "false" if state == "off" else "true"
244250 appliance = self ._appliances .find (f'appliance[@id="{ appl_id } "]' )
@@ -253,13 +259,15 @@ async def set_switch_state(
253259 await self .call_request (APPLIANCES , method = "post" , data = data )
254260 return
255261
262+ # Handle group of switches
256263 data = f"<{ switch .func_type } ><state>{ state } </state></{ switch .func_type } >"
257- uri = f"{ APPLIANCES } ;id={ appl_id } /relay"
258264 if members is not None :
259265 return await self ._set_groupswitch_member_state (
260266 data , members , state , switch
261267 )
262268
269+ # Handle individual relay switches
270+ uri = f"{ APPLIANCES } ;id={ appl_id } /relay"
263271 if model == "relay" :
264272 locator = (
265273 f'appliance[@id="{ appl_id } "]/{ switch .actuator } /{ switch .func_type } /lock'
0 commit comments