@@ -583,9 +583,10 @@ async def energy_log_update(
583583 ) -> tuple [bool , bool ]:
584584 """Request energy logs from node and store them.
585585
586- Return first bool as True if processing succeeded (records stored in memory, possibly all-empty).
587- Return first bool as False on transport or address errors.
588- Return second bool as False when all slots are empty or outdated; otherwise True.
586+ First bool: True when processing succeeded (records stored in memory, possibly all-empty);
587+ False only on transport or address errors.
588+ Second bool: slots_empty — True when all four slots at the address are empty or outdated;
589+ False when at least one recent, non-empty record was stored.
589590 """
590591 result = False
591592 slots_empty = True
@@ -618,17 +619,13 @@ async def energy_log_update(
618619 _LOGGER .debug (
619620 "In slot=%s: pulses=%s, timestamp=%s" , _slot , log_pulses , log_timestamp
620621 )
622+ address = response .log_address
623+ log_timestamp = log_timestamp .replace (tzinfo = UTC )
621624 if log_timestamp is None or log_pulses is None :
622- self ._energy_counters .add_empty_log (response .log_address , _slot )
623- elif self ._check_timestamp_is_recent (
624- response .log_address , _slot , log_timestamp .replace (tzinfo = UTC )
625- ):
625+ self ._energy_counters .add_empty_log (address , _slot )
626+ elif self ._check_timestamp_is_recent (address , _slot , log_timestamp ):
626627 self ._energy_counters .add_pulse_log (
627- response .log_address ,
628- _slot ,
629- log_timestamp .replace (tzinfo = UTC ),
630- log_pulses ,
631- import_only = True ,
628+ address , _slot , log_timestamp , log_pulses , import_only = True ,
632629 )
633630 cache_updated = True
634631
0 commit comments