Repository navigation
ina2xx_v2: fix total energy doubling on every boot - #33
Merged
Merged
Conversation
The MQTT callback and loop() run on different tasks and both applied the retained restore. Apply it from loop() only, keep a deferred restore from being wiped by our own echo, reject implausible retained values, and use double for the accumulators so small increments are not lost to rounding. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Until the restore was done, every sensor publish was retained without the energy fields. If one reached the broker before the retained state was read back, it replaced the stored totals, and the restore then took the device's own echo, found no energy values and restarted from zero (EleksTube lost 3.88 kWh this way). - Publish non-retained until the restore is done - Only a message containing total_energy_kWh starts the restore - If none arrives within 30 s of MQTT connecting, count from current values Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
Author
|
localy added |
KrX3D
pushed a commit
that referenced
this pull request
Nov 18, 2026
…tore Brings in #33. This branch had converted ina2xx_v2.cpp from CRLF to LF, so its diff rewrote the whole file and reverted #33. The merge keeps 0_15's line endings and re-applies only the template change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 18, 2026
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.
Changelog
total_energy_kWhstarts the restore, and after 30 s without one it counts from the current values.🤖 Generated with Claude Code