@@ -448,9 +448,11 @@ async def get_missing_energy_logs(self) -> None:
448448 self ._mac_in_str ,
449449 )
450450 total_addresses = 11
451+ _LOGGER .debug ("_last_collected_energy_timestamp: %s" , self ._last_collected_energy_timestamp )
451452 log_address = self ._current_log_address
452453 prev_address_timestamp : datetime | None = None
453454 log_interval = self .energy_consumption_interval
455+ _LOGGER .debug ("log_interval: %s" , log_interval )
454456 factor = 4
455457 if self .energy_production_interval is not None :
456458 factor = 2
@@ -459,29 +461,33 @@ async def get_missing_energy_logs(self) -> None:
459461 await self .energy_log_update (log_address )
460462 # Check if the most recent timestamp of the current address is recent
461463 # (within 2/4 * log_interval plus 5 mins margin)
462- if (
463- log_address == self ._current_log_address
464- and self ._last_collected_energy_timestamp is not None
465- and log_interval is not None
466- and (
467- datetime .now (tz = UTC ) - self ._last_collected_energy_timestamp
468- ).total_seconds () // 60 > (factor * log_interval ) + 5 # minutes
469- ):
470- _LOGGER .debug ("Energy data collected is outdated, stopping collection" )
471- break
464+ if log_address == self ._current_log_address :
465+ if (
466+ self ._last_collected_energy_timestamp is not None
467+ and log_interval is not None
468+ and (
469+ datetime .now (tz = UTC ) - self ._last_collected_energy_timestamp
470+ ).total_seconds () // 60 > (factor * log_interval ) + 5 # minutes
471+ ):
472+ _LOGGER .debug ("Energy data collected is outdated, stopping collection" )
473+ break
474+
475+ "if pulses=None and timestamp == None:"
476+ " break"
472477
473478 # Check if the most recent timestamp of an earlier address is recent
474- if (
475- log_address != self ._current_log_address
476- and self ._last_collected_energy_timestamp is not None
477- and log_interval is not None
478- and prev_address_timestamp is not None
479- and (
480- prev_address_timestamp - self ._last_collected_energy_timestamp
481- ).total_seconds () // 60 > (factor * log_interval ) + 5 # minutes
482- ):
483- _LOGGER .debug ("Energy data collected is outdated, stopping collection" )
484- break
479+ else :
480+ _LOGGER .debug ("prev_address_timestamp: %s" , prev_address_timestamp )
481+ if (
482+ self ._last_collected_energy_timestamp is not None
483+ and log_interval is not None
484+ and prev_address_timestamp is not None
485+ and (
486+ prev_address_timestamp - self ._last_collected_energy_timestamp
487+ ).total_seconds () // 60 > (factor * log_interval ) + 5 # minutes
488+ ):
489+ _LOGGER .debug ("Energy data collected is outdated, stopping collection" )
490+ break
485491
486492 if self ._last_collected_energy_timestamp is not None :
487493 prev_address_timestamp = self ._last_collected_energy_timestamp
0 commit comments