Skip to content

Commit 405ec7e

Browse files
authored
Merge pull request #312 from plugwise/mdi_sed
properly propagate configuration changes
2 parents 77b0375 + dcb8909 commit 405ec7e

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Ongoing
44

55
- PR [319](https://github.com/plugwise/python-plugwise-usb/pull/319): Replace unclear warning message when a node is not online, also various small improvements suggested by CRAI.
6+
- PR [312](https://github.com/plugwise/python-plugwise-usb/pull/312): properly propagate configuration changes and initialize to available on first node wakeup
67

78
## v0.44.11 - 2025-08-14
89

plugwise_usb/nodes/scan.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ async def load(self) -> None:
102102
await super().load()
103103

104104
self._setup_protocol(SCAN_FIRMWARE_SUPPORT, SCAN_FEATURES)
105-
await self.initialize()
106105
await self._loaded_callback(NodeEvent.LOADED, self.mac)
106+
await self.initialize()
107107

108108
async def initialize(self) -> None:
109109
"""Initialize Scan node."""
@@ -426,6 +426,10 @@ async def _run_awake_tasks(self) -> None:
426426
await super()._run_awake_tasks()
427427
if self._motion_config.dirty:
428428
await self._configure_scan_task()
429+
await self.publish_feature_update_to_subscribers(
430+
NodeFeature.MOTION_CONFIG,
431+
self._motion_config,
432+
)
429433

430434
async def _configure_scan_task(self) -> bool:
431435
"""Configure Scan device settings. Returns True if successful."""

plugwise_usb/nodes/sed.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,15 @@ async def set_awake_duration(self, seconds: int) -> bool:
237237
raise ValueError(
238238
f"Invalid awake duration ({seconds}). It must be between 1 and 255 seconds."
239239
)
240+
if self._battery_config.awake_duration == seconds:
241+
return False
240242

241243
self._battery_config = replace(
242244
self._battery_config,
243245
awake_duration=seconds,
244246
dirty=True,
245247
)
248+
await self._sed_configure_update()
246249
return True
247250

248251
async def set_clock_interval(self, minutes: int) -> bool:
@@ -264,6 +267,7 @@ async def set_clock_interval(self, minutes: int) -> bool:
264267
self._battery_config = replace(
265268
self._battery_config, clock_interval=minutes, dirty=True
266269
)
270+
await self._sed_configure_update()
267271
return True
268272

269273
async def set_clock_sync(self, sync: bool) -> bool:
@@ -280,6 +284,7 @@ async def set_clock_sync(self, sync: bool) -> bool:
280284
self._battery_config = replace(
281285
self._battery_config, clock_sync=sync, dirty=True
282286
)
287+
await self._sed_configure_update()
283288
return True
284289

285290
async def set_maintenance_interval(self, minutes: int) -> bool:
@@ -301,6 +306,7 @@ async def set_maintenance_interval(self, minutes: int) -> bool:
301306
self._battery_config = replace(
302307
self._battery_config, maintenance_interval=minutes, dirty=True
303308
)
309+
await self._sed_configure_update()
304310
return True
305311

306312
async def set_sleep_duration(self, minutes: int) -> bool:
@@ -325,6 +331,7 @@ async def set_sleep_duration(self, minutes: int) -> bool:
325331
self._battery_config = replace(
326332
self._battery_config, sleep_duration=minutes, dirty=True
327333
)
334+
await self._sed_configure_update()
328335
return True
329336

330337
# endregion

tests/test_usb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,14 +2000,14 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
20002000
awake_response2.timestamp = awake_response1.timestamp + td(
20012001
seconds=pw_sed.AWAKE_RETRY
20022002
)
2003-
assert await test_sed.set_awake_duration(15)
2003+
assert await test_sed.set_awake_duration(20)
20042004
assert test_sed.battery_config.dirty
20052005
mock_stick_controller.send_response = sed_config_accepted
20062006
await test_sed._awake_response(awake_response2) # pylint: disable=protected-access
20072007
await asyncio.sleep(0.001) # Ensure time for task to be executed
20082008
assert not test_sed.battery_config.dirty
2009-
assert test_sed.battery_config.awake_duration == 15
2010-
assert test_sed.awake_duration == 15
2009+
assert test_sed.battery_config.awake_duration == 20
2010+
assert test_sed.awake_duration == 20
20112011

20122012
# test maintenance interval
20132013
assert test_sed.maintenance_interval == 60

0 commit comments

Comments
 (0)