Skip to content

Commit 36f9ba9

Browse files
committed
Circle: add relay-lock
1 parent f7276eb commit 36f9ba9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def __init__(
8484
super().__init__(mac, address, controller, loaded_callback)
8585

8686
# Relay
87+
self._relay_lock = False
8788
self._relay_state: RelayState = RelayState()
8889
self._relay_config: RelayConfig = RelayConfig()
8990

@@ -175,6 +176,15 @@ async def relay_init_on(self) -> None:
175176
"""Switch relay on."""
176177
await self._relay_init_set(True)
177178

179+
@property
180+
def relay_lock(self) -> bool:
181+
"""State of the relay lock."""
182+
return self._relay_lock
183+
184+
def set_relay_lock(self, state: bool) -> None:
185+
"""Set the state of the relay-lock."""
186+
self._relay_lock = state
187+
178188
# endregion
179189

180190
async def calibration_update(self) -> bool:
@@ -643,6 +653,10 @@ async def set_relay(self, state: bool) -> bool:
643653
raise FeatureError(
644654
f"Changing state of relay is not supported for node {self.mac}"
645655
)
656+
657+
if self._relay_lock:
658+
raise NodeError("Changing state of relay failed, it is locked")
659+
646660
_LOGGER.debug("set_relay() start")
647661
request = CircleRelaySwitchRequest(self._send, self._mac_in_bytes, state)
648662
response = await request.send()

0 commit comments

Comments
 (0)