Skip to content

Commit 61af89c

Browse files
committed
Increase use-cases for set_switch_state
1 parent 78fef1d commit 61af89c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

plugwise/smile.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,17 @@ async def set_temperature(self, loc_id, temperature):
371371
async def set_switch_state(self, appl_id, members, model, state):
372372
"""Switch the Switch off/on."""
373373
actuator = "actuator_functionalities"
374-
func_type = "relay_functionality"
375374
device = "relay"
375+
func_type = "relay_functionality"
376+
func = "state"
376377
if model == "dhw_cm_switch":
377-
func_type = "toggle_functionality"
378378
device = "toggle"
379+
func_type = "toggle_functionality"
380+
381+
if model == "lock":
382+
func = "lock"
383+
state = "false" if state == "off" else "true"
384+
379385
stretch_v2 = self.smile_type == "stretch" and self.smile_version[1].major == 2
380386
if stretch_v2:
381387
actuator = "actuators"
@@ -399,8 +405,7 @@ async def set_switch_state(self, appl_id, members, model, state):
399405
uri = f"{APPLIANCES};id={appl_id}/{device};id={switch_id}"
400406
if stretch_v2:
401407
uri = f"{APPLIANCES};id={appl_id}/{device}"
402-
state = str(state)
403-
data = f"<{func_type}><state>{state}</state></{func_type}>"
408+
data = f"<{func_type}><{func}>{state}</{func}></{func_type}>"
404409

405410
await self.request(uri, method="put", data=data)
406411
return True

0 commit comments

Comments
 (0)