fix(inverter): count a commit button press as a register write - #5123
Open
chalfontchubby wants to merge 1 commit into
Open
chalfontchubby wants to merge 1 commit into
chalfontchubby wants to merge 1 commit into
Conversation
press_and_poll_button() never incremented count_register_writes, so a cycle whose only write was the button press still reported "count register writes 0" and the install's register-write total never moved. On inverters that need a button press to apply a schedule the press is a real write - on Solis a non-volatile one, which is the flash/EEPROM wear concern in #2328 - so it belongs in the same count as the register writes it commits. Not counting it also hid the repeated-press bug in #4712 from the people best placed to notice it: the reporter there found their button being pressed twice per cycle while Predbat reported no writes at all. Both press paths are covered - the combined toggle-switch button and the press-and-poll button entity. Addresses #4712. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
(Written by Claude, posted by @chalfontchubby.)
Problem
press_and_poll_button()never incrementedcount_register_writes, so a cycle whose only write was the button press still reportedcount register writes 0and the install's register-write total never moved.From the log attached to #4712, on an older-firmware Solis via solax_modbus:
Every register reports "No write needed", the button is pressed anyway, and the cycle is recorded as zero writes.
Why it matters
On inverters that need a button press to apply a schedule, the press is a real write — on Solis a non-volatile one, which is the flash/EEPROM wear concern in #2328. It belongs in the same count as the register writes it commits.
Not counting it also hid a repeated-press bug from the people best placed to notice it. The reporter on #4712 found their button being pressed once or twice per cycle while Predbat reported no writes at all, and said so directly:
Change
One increment on each of the two success paths in
press_and_poll_button()— the combined toggle-switch button and the press-and-poll button entity. Failure paths are untouched, so a press that did not land is still not counted.Scope
This is instrumentation only: it makes existing presses visible, it does not change how often the button is pressed. The separate repeated-press defect in #4712 is being worked on independently and does not depend on this.
Testing
test_button_press_counts_as_register_writeasserts one press counts as exactly one register write, saving and restoring the shared fixture state it touches (Test infrastructure keeps producing fixture state-leak bugs #5079)Addresses #4712.