Repository navigation
Control read-back: block reads and a confirming re-read before rewrites - #56
Merged
Merged
Conversation
About a quarter of the live control writes re-write the value written last (351 of 462 battery_charge_current writes, typically 15-20 min apart), barely correlated with link timeouts. The log can't tell an inverter that resets the register from a bad read, so each write now logs what was read and whether it is for a new target or re-applies an unchanged one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The inverter's Wi-Fi module sometimes answers a request with the reply to the previous one. With one-register reads in a row the library (which only checks the reply length) took one setting's value for the next one's: discharge depth read 190 (raw discharge current 19.0 A), charge current read 0.0 / 360.0 (EMS power limit 0 / 3600). The writer then rewrote a register that was fine - ~300 of ~1,220 writes on 2026-11-19..28. - Read 47511-47512 and 45353-45356 as one request each, so a leftover reply has the wrong length and is rejected (also 4 requests per read-back instead of 7). - A mismatch on an unchanged, already applied target is confirmed by a second read before it costs a write; a new target is written at once. - Depth/currents outside 0-100 are ignored as bad reads. Co-Authored-By: Claude Opus 5.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.
Problem
About a quarter of all control writes (~300 of ~1,220 on 2026-11-19..28) were rewrites of registers that were fine. The inverter's Wi-Fi module sometimes answers a request with the reply to the previous one. A Modbus read reply doesn't say which registers it holds, and goodwe only checks its length, so with one-register reads in a row one setting's value arrived as the next one's:
battery_discharge_depth= 190 (129×)battery_discharge_current19.0 A, read just beforebattery_charge_current= 0.0 (140×) / 360.0 (23×)ems_power_limit0 / 3600 scaled /10The same module behaviour shows up as the ~1,500
Response has unexpected lengthlines a day (rejected only because those lengths differed).Change (
control_io.py)ems_mode+ems_power_limit(47511-47512) and charge current / discharge current / discharge depth (45353-45356) are read with one request each. A leftover reply then has the wrong length and is rejected. A read-back is now 4 requests instead of 7.Control read-back {...} not confirmed by a re-read - no write). A register the inverter really reset is still written once; a new target is written at once, with no extra read.out of range - ignored).Inverters without goodwe's internals (the test fakes) fall back to one read per setting.
This branch sits on
control-write-log-readback(e42bad4, the write log with the read-back and cause, which is how the problem was found). That commit has no PR of its own and is included here.Tests
python -m unittest discover -s tests: 615 OK. New: block read against the real goodwe ET register map (one request per block, decoding), one bad read gives no write, a real reset is rewritten once, 190 ignored, a new target isn't delayed by a re-read.🤖 Generated with Claude Code