Skip to content

Commit c9f7134

Browse files
committed
Alternative method of getting/setting accept_joiN_request
Remove get_ Fix
1 parent 1ee8e13 commit c9f7134

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

plugwise_usb/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ def accept_join_request(self) -> bool | None:
190190
return None
191191
return self._network.accept_join_request
192192

193-
@accept_join_request.setter
194-
def accept_join_request(self, state: bool) -> None:
193+
async def set_accept_join_request(self, state: bool) -> None:
195194
"""Configure join request setting."""
196195
if not self._controller.is_connected:
197196
raise StickError(
@@ -205,8 +204,9 @@ def accept_join_request(self, state: bool) -> None:
205204
+ "without node discovery be activated. Call discover() first."
206205
)
207206

208-
self._network.accept_join_request = state
209-
_ = create_task(self._network.allow_join_requests(state))
207+
if self._network.accept_join_request != state:
208+
self._network.accept_join_request = state
209+
await self._network.allow_join_requests(state)
210210

211211
async def clear_cache(self) -> None:
212212
"""Clear current cache."""

tests/test_usb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ async def test_stick_connect(self, monkeypatch: pytest.MonkeyPatch) -> None:
469469
assert stick.accept_join_request is None
470470
# test failing of join requests without active discovery
471471
with pytest.raises(pw_exceptions.StickError):
472-
stick.accept_join_request = True
472+
await stick.set_accept_join_request(True)
473473
unsub_connect()
474474
await stick.disconnect()
475475
assert not stick.network_state
@@ -572,7 +572,7 @@ async def test_stick_node_discovered_subscription(
572572
await stick.connect()
573573
await stick.initialize()
574574
await stick.discover_nodes(load=False)
575-
stick.accept_join_request = True
575+
await stick.set_accept_join_request(True)
576576
self.test_node_awake = asyncio.Future()
577577
unsub_awake = stick.subscribe_to_node_events(
578578
node_event_callback=self.node_awake,

0 commit comments

Comments
 (0)