Skip to content

Commit 44f9f18

Browse files
committed
Don't switch a relay when locked
This will also help showing the correct state in Core.
1 parent 04c8e9d commit 44f9f18

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

plugwise/smile.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,17 @@ async def set_switch_state(self, appl_id, members, model, state):
407407
uri = f"{APPLIANCES};id={appl_id}/{device}"
408408
data = f"<{func_type}><{func}>{state}</{func}></{func_type}>"
409409

410+
if model == "relay":
411+
locator = f'appliance[@id="{appl_id}"]/{actuator}/{func_type}/lock'
412+
lock_state = self._appliances.find(locator).text
413+
print("Lock state: ", lock_state)
414+
# Don't bother switching a relay when the corresponding lock-state is true
415+
if lock_state == "true":
416+
return False
417+
else:
418+
await self.request(uri, method="put", data=data)
419+
return True
420+
410421
await self.request(uri, method="put", data=data)
411422
return True
412423

0 commit comments

Comments
 (0)