Skip to content

fix(telemetry): exclude untimestamped points from the lifetime energy total - #123

Merged
KRoperUK merged 1 commit into
mainfrom
fix/120-untimestamped-lifetime
Oct 9, 2026
Merged

KRoperUK merged 1 commit into
mainfrom
fix/120-untimestamped-lifetime

Conversation

@KRoperUK

@KRoperUK KRoperUK commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Summary

summarise_energy summed every parsed point in lifetime (and the default) mode, including points whose timestamp could not be parsed (ts is None), while daily/window modes dropped them via filter_telemetry_points. An untimestamped point therefore inflated the lifetime total but could never appear in any day, so the cumulative total could not be reconciled against the sum of its days — silent drift into the Home Assistant Energy Dashboard's TOTAL_INCREASING lifetime sensor.

This drops ts is None points from the lifetime path too, so all three modes agree. Closes #120.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change
  • Documentation / chore

Checklist

  • ruff check . passes
  • ruff format --check . passes
  • mypy passes — the config is strict (no issues, 9 source files)
  • pytest passes and new/changed behaviour is covered by tests (198 passed)
  • I have updated the README / docstrings / docs/ where relevant (summarise_energy docstring now states the untimestamped-point behaviour)

Behaviour changes worth calling out

Minor, deliberate behaviour change for consumers: a payload containing untimestamped points now yields a smaller lifetime total (the untimestamped values are excluded), and an all-untimestamped payload totals 0.0. This is the intended correction — those points cannot be placed on a calendar day, so including them only in the lifetime total was the bug. Verified the new test fails against pristine main (lifetime 6.0 vs the corrected 4.0) and passes with the fix.

summarise_energy summed every parsed point in lifetime/default mode,
including points whose timestamp could not be parsed (ts is None), while
daily/window modes dropped them via filter_telemetry_points. An
untimestamped point therefore inflated the lifetime total but could never
appear in any day, so the cumulative meter could not be reconciled against
the sum of its days -- silent drift into the HA Energy Dashboard's
TOTAL_INCREASING sensor.

Drop ts is None points from the lifetime path too, matching daily/window,
so the totals reconcile.

Closes #120
@KRoperUK
KRoperUK enabled auto-merge (squash) October 9, 2026 15:35
@KRoperUK
KRoperUK merged commit e20361d into main Oct 9, 2026
10 checks passed
@KRoperUK
KRoperUK deleted the fix/120-untimestamped-lifetime branch October 9, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

summarise_energy: untimestamped points inflate lifetime but are dropped from daily/window, so totals can't reconcile

1 participant