Skip to content

Control read-back: block reads and a confirming re-read before rewrites - #56

Merged
piomar123 merged 2 commits into
mainfrom
control-block-reads
Nov 30, 2026
Merged

piomar123 merged 2 commits into
mainfrom
control-block-reads

Conversation

@piomar123

Copy link
Copy Markdown
Owner

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:

Logged read-back Actually
battery_discharge_depth = 190 (129×) raw battery_discharge_current 19.0 A, read just before
battery_charge_current = 0.0 (140×) / 360.0 (23×) ems_power_limit 0 / 3600 scaled /10

The same module behaviour shows up as the ~1,500 Response has unexpected length lines a day (rejected only because those lengths differed).

Change (control_io.py)

  • Block reads: 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.
  • Confirming re-read: a mismatch on a target that was applied and hasn't changed is read again before it costs a write (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.
  • Plausibility: depth/currents outside 0-100 are ignored (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

piomar123 and others added 2 commits November 4, 2026 20:10
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>
@piomar123
piomar123 merged commit 252e0be into main Nov 30, 2026
1 check passed
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