@@ -381,7 +381,9 @@ async def energy_update(self) -> EnergyStatistics | None: # noqa: PLR0911 PLR09
381381 return None
382382
383383 # Try collecting energy-stats for _current_log_address
384- result = await self .energy_log_update (self ._current_log_address , save_cache = True )
384+ result = await self .energy_log_update (
385+ self ._current_log_address , save_cache = True
386+ )
385387 if not result :
386388 _LOGGER .debug (
387389 "async_energy_update | %s | Log rollover | energy_log_update from address %s failed" ,
@@ -415,7 +417,9 @@ async def energy_update(self) -> EnergyStatistics | None: # noqa: PLR0911 PLR09
415417 return self ._energy_counters .energy_statistics
416418
417419 if len (missing_addresses ) == 1 :
418- result = await self .energy_log_update (missing_addresses [0 ], save_cache = True )
420+ result = await self .energy_log_update (
421+ missing_addresses [0 ], save_cache = True
422+ )
419423 if result :
420424 await self .power_update ()
421425 _LOGGER .debug (
@@ -528,7 +532,9 @@ async def get_missing_energy_logs(self) -> None:
528532 if self ._cache_enabled :
529533 await self ._energy_log_records_save_to_cache ()
530534
531- async def energy_log_update (self , address : int | None , save_cache : bool = True ) -> bool :
535+ async def energy_log_update (
536+ self , address : int | None , save_cache : bool = True
537+ ) -> bool :
532538 """Request energy logs and return True only when at least one recent, non-empty record was stored; otherwise return False."""
533539 any_record_stored = False
534540 if address is None :
@@ -590,8 +596,7 @@ def _check_timestamp_is_recent(
590596 ) -> bool :
591597 """Check if a log record timestamp is within the last MAX_LOG_HOURS hours."""
592598 age_seconds = max (
593- 0.0 ,
594- (datetime .now (tz = UTC ) - timestamp .replace (tzinfo = UTC )).total_seconds ()
599+ 0.0 , (datetime .now (tz = UTC ) - timestamp .replace (tzinfo = UTC )).total_seconds ()
595600 )
596601 if age_seconds > MAX_LOG_HOURS * 3600 :
597602 _LOGGER .warning (
0 commit comments