Skip to content

fix(inverter): count a commit button press as a register write - #5123

Open
chalfontchubby wants to merge 1 commit into
mainfrom
fix/count-button-press-as-write
Open

chalfontchubby wants to merge 1 commit into
mainfrom
fix/count-button-press-as-write

Conversation

@chalfontchubby

Copy link
Copy Markdown
Collaborator

(Written by Claude, posted by @chalfontchubby.)

Problem

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.

From the log attached to #4712, on an older-firmware Solis via solax_modbus:

Inverter 0 write_and_poll_value: No write needed for discharge_end_hour: 0 == 0.0 fuzzy 0
Inverter 0 write_and_poll_value: No write needed for discharge_end_minute: 0 == 0.0 fuzzy 0
Inverter 0 successfully pressed button button.inverter_update_charge_discharge_times
...
Inverter 0 count register writes 0
Total inverter register writes now 4081

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:

Please note also that the inverter writes counter is not being updated by this, hence it is hidden from many users.

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

Addresses #4712.

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

1 participant