Skip to content

Commit 15aaff0

Browse files
committed
Also check if energy data from the current address is recent
- likely to be not after an energy-reset
1 parent 8be2821 commit 15aaff0

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

plugwise_usb/nodes/circle.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,19 @@ async def get_missing_energy_logs(self) -> None:
456456

457457
while total_addresses > 0:
458458
await self.energy_log_update(log_address)
459-
# Check if the most recent timestamp of an earlier address is recent
459+
# Check if the most recent timestamp of the current address is recent
460460
# (within 2/4 * log_interval plus 5 mins margin)
461+
if (
462+
log_address == self._current_log_address
463+
and self._last_collected_energy_timestamp is not None
464+
and (
465+
datetime.now(tz=UTC) - self._last_collected_energy_timestamp
466+
).total_seconds() // 60 > (factor * log_interval) + 5 # minutes
467+
):
468+
_LOGGER.debug("Energy data collected is outdated, stopping collection")
469+
break
470+
471+
# Check if the most recent timestamp of an earlier address is recent
461472
if (
462473
log_address != self._current_log_address
463474
and self._last_collected_energy_timestamp is not None

0 commit comments

Comments
 (0)