Skip to content

Commit 2e0e24f

Browse files
committed
Simplify lock_state to state
1 parent c27077d commit 2e0e24f

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

plugwise_usb/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class RelayConfig:
176176
class RelayLock:
177177
"""Status of relay lock."""
178178

179-
lock_state: bool | None = None
179+
state: bool | None = None
180180

181181

182182
@dataclass(frozen=True)

plugwise_usb/nodes/circle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __init__(
8686
super().__init__(mac, address, controller, loaded_callback)
8787

8888
# Relay
89-
self._relay_lock: RelayLock = RelayLock(lock_state=False)
89+
self._relay_lock: RelayLock = RelayLock(state=False)
9090
self._relay_state: RelayState = RelayState()
9191
self._relay_config: RelayConfig = RelayConfig()
9292

@@ -644,7 +644,7 @@ async def set_relay(self, state: bool) -> bool:
644644
f"Changing state of relay is not supported for node {self.mac}"
645645
)
646646

647-
if getattr(self._relay_lock, "lock_state"):
647+
if getattr(self._relay_lock, "state"):
648648
raise NodeError("Changing state of relay failed, it is locked")
649649

650650
_LOGGER.debug("set_relay() start")
@@ -722,7 +722,7 @@ async def _relay_update_lock(self, state: bool) -> None:
722722
if self._relay_lock:
723723
state_update = True
724724

725-
self._relay_lock = replace(self._relay_lock, lock_state=state)
725+
self._relay_lock = replace(self._relay_lock, state=state)
726726
if state_update:
727727
await self.publish_feature_update_to_subscribers(
728728
NodeFeature.RELAY_LOCK, self._relay_lock

tests/test_usb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -792,13 +792,13 @@ async def test_node_relay_and_power(self, monkeypatch: pytest.MonkeyPatch) -> No
792792
# Test blocked async switching due to relay-lock active
793793
await stick.nodes["0098765432101234"].set_relay_lock(True)
794794
assert stick.nodes["0098765432101234"].relay_lock
795-
assert stick.nodes["0098765432101234"].relay_lock.lock_state
795+
assert stick.nodes["0098765432101234"].relay_lock.state
796796
with pytest.raises(pw_exceptions.NodeError):
797797
await stick.nodes["0098765432101234"].set_relay(True)
798798
assert not stick.nodes["0098765432101234"].relay
799799
# Make sure to turn lock off for further testing
800800
await stick.nodes["0098765432101234"].set_relay_lock(False)
801-
assert not stick.nodes["0098765432101234"].relay_lock.lock_state
801+
assert not stick.nodes["0098765432101234"].relay_lock.state
802802

803803
# Test async switching back from off to on
804804
self.test_relay_state_on = asyncio.Future()
@@ -2513,7 +2513,7 @@ async def test_node_discovery_and_load(
25132513
assert state[pw_api.NodeFeature.INFO].version == "070073"
25142514

25152515
assert state[pw_api.NodeFeature.RELAY].state
2516-
assert not state[pw_api.NodeFeature.RELAY_LOCK].lock_state
2516+
assert not state[pw_api.NodeFeature.RELAY_LOCK].state
25172517

25182518
# Check 1111111111111111
25192519
get_state_timestamp = dt.now(UTC).replace(minute=0, second=0, microsecond=0)
@@ -2550,7 +2550,7 @@ async def test_node_discovery_and_load(
25502550
)
25512551
assert state[pw_api.NodeFeature.AVAILABLE].state
25522552
assert state[pw_api.NodeFeature.RELAY].state
2553-
assert not state[pw_api.NodeFeature.RELAY_LOCK].lock_state
2553+
assert not state[pw_api.NodeFeature.RELAY_LOCK].state
25542554

25552555

25562556
# region Scan

0 commit comments

Comments
 (0)