Repository navigation
fix(telemetry): exclude untimestamped points from the lifetime energy total - #123
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
summarise_energysummed every parsed point inlifetime(and the default) mode, including points whose timestamp could not be parsed (ts is None), whiledaily/windowmodes dropped them viafilter_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'sTOTAL_INCREASINGlifetime sensor.This drops
ts is Nonepoints from the lifetime path too, so all three modes agree. Closes #120.Type of change
Checklist
ruff check .passesruff format --check .passesmypypasses — the config isstrict(no issues, 9 source files)pytestpasses and new/changed behaviour is covered by tests (198 passed)docs/where relevant (summarise_energydocstring 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
lifetimetotal (the untimestamped values are excluded), and an all-untimestamped payload totals0.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 pristinemain(lifetime 6.0 vs the corrected 4.0) and passes with the fix.