Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Ongoing

- 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.
- PR [312](https://github.com/plugwise/python-plugwise-usb/pull/312): properly propagate configuration changes and initialize to available on first node wakeup

## v0.44.11 - 2025-08-14

Expand Down
6 changes: 5 additions & 1 deletion plugwise_usb/nodes/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ async def load(self) -> None:
await super().load()

self._setup_protocol(SCAN_FIRMWARE_SUPPORT, SCAN_FEATURES)
await self.initialize()
await self._loaded_callback(NodeEvent.LOADED, self.mac)
await self.initialize()

async def initialize(self) -> None:
"""Initialize Scan node."""
Expand Down Expand Up @@ -426,6 +426,10 @@ async def _run_awake_tasks(self) -> None:
await super()._run_awake_tasks()
if self._motion_config.dirty:
await self._configure_scan_task()
await self.publish_feature_update_to_subscribers(
NodeFeature.MOTION_CONFIG,
self._motion_config,
)

async def _configure_scan_task(self) -> bool:
"""Configure Scan device settings. Returns True if successful."""
Expand Down
7 changes: 7 additions & 0 deletions plugwise_usb/nodes/sed.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,15 @@ async def set_awake_duration(self, seconds: int) -> bool:
raise ValueError(
f"Invalid awake duration ({seconds}). It must be between 1 and 255 seconds."
)
if self._battery_config.awake_duration == seconds:
return False

self._battery_config = replace(
self._battery_config,
awake_duration=seconds,
dirty=True,
)
await self._sed_configure_update()
return True

async def set_clock_interval(self, minutes: int) -> bool:
Expand All @@ -264,6 +267,7 @@ async def set_clock_interval(self, minutes: int) -> bool:
self._battery_config = replace(
self._battery_config, clock_interval=minutes, dirty=True
)
await self._sed_configure_update()
return True

async def set_clock_sync(self, sync: bool) -> bool:
Expand All @@ -280,6 +284,7 @@ async def set_clock_sync(self, sync: bool) -> bool:
self._battery_config = replace(
self._battery_config, clock_sync=sync, dirty=True
)
await self._sed_configure_update()
return True

async def set_maintenance_interval(self, minutes: int) -> bool:
Expand All @@ -301,6 +306,7 @@ async def set_maintenance_interval(self, minutes: int) -> bool:
self._battery_config = replace(
self._battery_config, maintenance_interval=minutes, dirty=True
)
await self._sed_configure_update()
return True

async def set_sleep_duration(self, minutes: int) -> bool:
Expand All @@ -325,6 +331,7 @@ async def set_sleep_duration(self, minutes: int) -> bool:
self._battery_config = replace(
self._battery_config, sleep_duration=minutes, dirty=True
)
await self._sed_configure_update()
return True

# endregion
Expand Down
6 changes: 3 additions & 3 deletions tests/test_usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2000,14 +2000,14 @@ async def load_callback(event: pw_api.NodeEvent, mac: str) -> None: # type: ign
awake_response2.timestamp = awake_response1.timestamp + td(
seconds=pw_sed.AWAKE_RETRY
)
assert await test_sed.set_awake_duration(15)
assert await test_sed.set_awake_duration(20)
assert test_sed.battery_config.dirty
mock_stick_controller.send_response = sed_config_accepted
await test_sed._awake_response(awake_response2) # pylint: disable=protected-access
await asyncio.sleep(0.001) # Ensure time for task to be executed
assert not test_sed.battery_config.dirty
assert test_sed.battery_config.awake_duration == 15
assert test_sed.awake_duration == 15
assert test_sed.battery_config.awake_duration == 20
assert test_sed.awake_duration == 20

# test maintenance interval
assert test_sed.maintenance_interval == 60
Expand Down