Skip to content

fix(growatt): leave a failed read out instead of sending 0 (2.2.2) - #273

Merged
frahlg merged 2 commits into
mainfrom
growatt-zeros
Nov 22, 2026
Merged

frahlg merged 2 commits into
mainfrom
growatt-zeros

Conversation

@frahlg

@frahlg frahlg commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

This is the never-fabricate half of #263. #265 fixed the battery sign.
Which registers the meter should read is #271 and is not changed here.

What was wrong

growatt 2.2.1 started every PV, battery and meter value at 0, so a read
that did not answer still sent a number: 0 W PV, 0 W meter, 0 V and 0 % SoC
on the battery, 0 Hz. docs/WRITING-A-DRIVER.md ("Never fabricate") says a
field that did not answer is left out, and a stream whose defining reading
did not answer is not emitted. A 0 W meter looks like a site in balance, a
0 % SoC like an empty pack.

Change (growatt 2.2.2)

  • Each field comes only from a read that answered with every register
    asked for. A shorter reply counts as failed, since a 32-bit decode would
    misread the missing word. The metrics follow the same rule.
  • PV goes out only when its power (1-2) answers. MPPT voltages and currents
    and the lifetime counter are left out when their reads fail.
  • The meter goes out only when its power (1015-1016) answers. Frequency,
    per-phase voltages and currents, and the energy counters are left out
    when their reads fail.
  • The gate on a stream is strict, as the docs say: "A stream whose defining
    reading did not answer is not emitted." So when the PV or meter power
    read fails, that poll also sends no PV lifetime counter or MPPT values,
    or no meter energy counters, frequency or phase values, even if those
    reads answered. The MPPT and phase values still reach history as
    metrics.
  • The battery keeps its presence check (Growatt PV-only installation appears as a battery on Overview ftw#1669), now only from
    reads that answered, and follows "A hybrid inverter may have no
    battery": each field comes only from a read that answered, and the
    stream goes out when what answered shows a battery. So a failed power
    read does not also drop a good SoC, as in ferroamp_modbus since feat(victron_mqtt, victron, ferroamp_modbus, zap): what the battery can do now #254.
    Its power needs both 1009 and 1011, since either alone is not the net.
  • growatt leaves drivers/tests/invented-number-baseline.json (was 16).
    make invented-number-report ID=growatt finds nothing, and
    make absent-register-report ID=growatt settles every register.

Tests

drivers/tests/test_growatt_never_fabricate.py, 13 tests: all answer; PV
power, MPPT, lifetime, meter power, phase and frequency, energy counters,
SoC, voltage and battery power each failing; both battery power reads
failing while voltage and SoC answer (the battery goes out without w); a
one-word reply to a two-word read; and nothing answering. 12 fail on
main; "all answer" passes there and checks values that must not change.
The existing growatt tests pass unchanged.

  • make test-driver ID=growatt: passes.
  • make check on main 0b8cc26: 5271 passed, 928 skipped.

Not verified on hardware

Not run against a real Growatt. On a healthy inverter the readings are the
same as before; the difference shows only when a read fails.

Refs #263

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T12:48:07.999315Z 5009a2c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

frahlg and others added 2 commits November 22, 2026 13:50
Every PV, battery and meter value started at 0, so a read that did not
answer sent 0 W, 0 V or 0 % SoC. Each field now comes only from a read
that answered with every register asked for. PV goes out only with its
power (1-2), the meter only with its power (1015-1016). The battery keeps
its presence check and gets each field only from a read that answered;
its power needs both 1009 and 1011. growatt leaves the invented-number
baseline. Harness tests for each failed read fail on main. Which registers
the meter should read is #271, unchanged here. Not
checked on hardware.

Refs #263

Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both 1009 and 1011 fail while voltage and SoC answer: the battery goes out
without w. A one-word reply to a two-word read is left out. Both tests fail
on main. The CHANGELOG now says that a failed PV or meter power read also
drops that stream's counters and phase values for the poll.

Refs #263

Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Co-Authored-By: Claude Opus 5.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