Skip to content

Commit d7f650a

Browse files
committed
Simplify, add support for lock-switching
1 parent fea476e commit d7f650a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

plugwise/legacy/smile.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,15 @@ async def set_switch_state(
238238
if self._stretch_v2:
239239
switch.actuator = "actuators"
240240
switch.func_type = "relay"
241-
switch.func = "state"
241+
242+
if model == "lock":
243+
state = "false" if state == "off" else "true"
242244

243245
if members is not None:
244246
return await self._set_groupswitch_member_state(members, state, switch)
245247

246-
data = f"<{switch.func_type}><{switch.func}>{state}</{switch.func}></{switch.func_type}>"
247-
uri = f"{APPLIANCES};id={appl_id}/relay"
248+
data = f"<{switch.func_type}><state>{state}</state></{switch.func_type}>"
249+
uri = f"{APPLIANCES};id={appl_id}/{model}"
248250

249251
if model == "relay":
250252
locator = (
@@ -261,10 +263,10 @@ async def _set_groupswitch_member_state(
261263
) -> None:
262264
"""Helper-function for set_switch_state().
263265
264-
Set the given State of the relevant Switch within a group of members.
266+
Set the given State of the relevant Switch (relay) within a group of members.
265267
"""
266268
for member in members:
267-
data = f"<{switch.func_type}><{switch.func}>{state}</{switch.func}></{switch.func_type}>"
269+
data = f"<{switch.func_type}><state>{state}</state></{switch.func_type}>"
268270
uri = f"{APPLIANCES};id={member}/relay"
269271

270272
await self.call_request(uri, method="put", data=data)

0 commit comments

Comments
 (0)