@@ -162,7 +162,6 @@ async def _load_from_cache(self) -> bool:
162162 dirty = True
163163 sleep_duration = SED_DEFAULT_SLEEP_DURATION
164164 dirty &= self ._sed_config_dirty_from_cache ()
165-
166165 self ._battery_config = BatteryConfig (
167166 awake_duration = awake_duration ,
168167 clock_interval = clock_interval ,
@@ -191,6 +190,9 @@ def _clock_interval_from_cache(self) -> int | None:
191190
192191 def _clock_sync_from_cache (self ) -> bool | None :
193192 """Load clock sync state from cache."""
193+ _LOGGER .debug (
194+ "MDI: Bool: %s" , str (self ._get_cache_as_bool (CACHE_SED_CLOCK_SYNC ))
195+ )
194196 return self ._get_cache_as_bool (CACHE_SED_CLOCK_SYNC )
195197
196198 def _maintenance_interval_from_cache (self ) -> int | None :
@@ -237,7 +239,9 @@ async def set_awake_duration(self, seconds: int) -> bool:
237239 )
238240
239241 self ._battery_config = replace (
240- self ._battery_config , awake_duration = seconds , dirty = True
242+ self ._battery_config ,
243+ awake_duration = seconds ,
244+ dirty = True ,
241245 )
242246 return True
243247
@@ -325,6 +329,11 @@ async def set_sleep_duration(self, minutes: int) -> bool:
325329
326330 # endregion
327331 # region Properties
332+ @property
333+ def dirty (self ) -> int :
334+ """Battry configuration dirty flag."""
335+ return self ._battery_config .dirty
336+
328337 @property
329338 def awake_duration (self ) -> int :
330339 """Duration in seconds a battery powered devices is awake."""
@@ -341,6 +350,7 @@ def battery_config(self) -> BatteryConfig:
341350 clock_sync = self .clock_sync ,
342351 maintenance_interval = self .maintenance_interval ,
343352 sleep_duration = self .sleep_duration ,
353+ dirty = self .dirty ,
344354 )
345355
346356 @property
@@ -413,17 +423,17 @@ async def _awake_response(self, response: PlugwiseResponse) -> bool:
413423 ):
414424 return True
415425
426+ await self ._run_awake_tasks ()
416427 self ._last_awake [response .awake_type ] = response .timestamp
417428
418429 tasks : list [Coroutine [Any , Any , None ]] = [
419- await self ._reset_awake (response .timestamp ),
430+ self ._reset_awake (response .timestamp ),
420431 self .publish_feature_update_to_subscribers (
421432 NodeFeature .BATTERY ,
422433 self ._battery_config ,
423434 ),
424- await self .save_cache (),
435+ self .save_cache (),
425436 ]
426- await self ._run_awake_tasks ()
427437 if response .awake_type == NodeAwakeResponseType .MAINTENANCE :
428438 self ._last_awake_reason = "Maintenance"
429439 self ._set_cache (CACHE_SED_AWAKE_REASON , "Maintenance" )
0 commit comments