@@ -448,16 +448,8 @@ async def get_missing_energy_logs(self) -> None:
448448 total_addresses = 11
449449 log_address = self ._current_log_address
450450 prev_address_timestamp : datetime | None = None
451- log_interval = self .energy_consumption_interval
452- _LOGGER .debug ("log_interval: %s" , log_interval )
453- factor = 4
454- if self .energy_production_interval is not None :
455- factor = 2
456-
457451 while total_addresses > 0 :
458452 await self .energy_log_update (log_address )
459- # Check if the most recent timestamp of the current address is recent
460- # (within 2/4 * log_interval plus 5 mins margin), or None
461453 if log_address == self ._current_log_address :
462454 if self ._last_collected_energy_timestamp is None :
463455 # Handle case with no data in slot 0
@@ -466,19 +458,16 @@ async def get_missing_energy_logs(self) -> None:
466458 )
467459 break
468460
469- elif (
470- log_interval is not None
471- and (
472- datetime .now (tz = UTC ) - self ._last_collected_energy_timestamp
473- ).total_seconds () // 60 > (factor * log_interval ) + 5 # minutes
474- ):
475- _LOGGER .debug (
476- "Energy data collected from the current log address is outdated, stopping collection"
477- )
478- break
479-
480461 # Check if the most recent timestamp of an earlier address is recent
462+ # (within 2/4 * log_interval plus 5 mins margin)
481463 else :
464+ log_interval = self .energy_consumption_interval
465+ _LOGGER .debug ("log_interval: %s" , log_interval )
466+ _LOGGER .debug ("energy_production_interval: %s" , self .energy_production_interval )
467+ factor = 4
468+ if self .energy_production_interval is not None :
469+ factor = 2
470+
482471 _LOGGER .debug ("prev_address_timestamp: %s" , prev_address_timestamp )
483472 if (
484473 self ._last_collected_energy_timestamp is not None
0 commit comments