File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -449,16 +449,22 @@ async def get_missing_energy_logs(self) -> None:
449449 total_addresses = 11
450450 log_address = self ._current_log_address
451451 prev_address_timestamp : datetime | None = None
452+ log_interval = self .energy_consumption_interval
453+ factor = 4
454+ if self .energy_production_interval is not None :
455+ factor = 2
456+
452457 while total_addresses > 0 :
453458 await self .energy_log_update (log_address )
454- # Check if the most recent timestamp of an earlier address is recent (4 * log_interval plus 5 mins margin)
459+ # Check if the most recent timestamp of an earlier address is recent
460+ # (within 2/4 * log_interval plus 5 mins margin)
455461 if (
456462 log_address != self ._current_log_address
457463 and self ._last_collected_energy_timestamp is not None
458464 and prev_address_timestamp is not None
459465 and (
460466 prev_address_timestamp - self ._last_collected_energy_timestamp
461- ).total_seconds () // 60 > (4 * 60 ) + 5 # minutes
467+ ).total_seconds () // 60 > (factor * log_interval ) + 5 # minutes
462468 ):
463469 _LOGGER .debug ("Energy data collected is outdated, stopping collection" )
464470 break
You can’t perform that action at this time.
0 commit comments