8000 Home load history: timezone-aware datetimes and additive backfill on manual collection · Issue #42 · edge-mining/app · GitHub
[go: up one dir, main page]

Skip to content

Home load history: timezone-aware datetimes and additive backfill on manual collection #42

Closed

Description

@markoceri

Problem

Two issues affect the home load consumption history.

  1. 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.

  2. 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.

Activity

  1. self-assigned this
    on Jun 28, 2026
  2. added a commit that references this issue on Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0