Problem
Two issues affect the home load consumption history.
-
Timezone mismatch. While building the per-device consumption in the optimization loop, the 24h look-back window is created with a naive datetime.now(), but Home Assistant and the persistence layer return timezone-aware (UTC) timestamps. The comparison fails with:
Error getting load history for device '...': can't compare offset-naive and offset-aware datetimes
The same naive/aware mix affects the history purge cut-off.
-
Manual collection ignores the look-back window. When power points already exist for a device, a manual collection only fetches incrementally from the last stored point, ignoring the requested lookback_hours. Requesting e.g. 30 days returns only the few most recent points and never backfills internal gaps.
Expected
- History datetimes are consistently timezone-aware (UTC).
- A manual collection honours the requested look-back window and backfills missing data additively, without dropping already-stored points (bounded by Home Assistant's recorder retention).
Notes
The scheduled periodic collection stays incremental for efficiency.
Problem
Two issues affect the home load consumption history.
Timezone mismatch. While building the per-device consumption in the optimization loop, the 24h look-back window is created with a naive
datetime.now(), but Home Assistant and the persistence layer return timezone-aware (UTC) timestamps. The comparison fails with:The same naive/aware mix affects the history purge cut-off.
Manual collection ignores the look-back window. When power points already exist for a device, a manual collection only fetches incrementally from the last stored point, ignoring the requested
lookback_hours. Requesting e.g. 30 days returns only the few most recent points and never backfills internal gaps.Expected
Notes
The scheduled periodic collection stays incremental for efficiency.