Skip to content

fix(growatt): read charge and discharge power the right way round (2.2.1) - #265

Merged
frahlg merged 1 commit into
mainfrom
fix-263
Nov 22, 2026
Merged

frahlg merged 1 commit into
mainfrom
fix-263

Conversation

@frahlg

@frahlg frahlg commented Nov 22, 2026

Copy link
Copy Markdown
Member

What was wrong

growatt 2.2.0 read input 1009-1010 as charge power and 1011-1012 as
discharge power. battery.w therefore had the wrong sign: a charging
battery showed as discharging and the reverse. The driver is read-only, so
no command went the wrong way, but the site balance, history and planning
input were wrong for every Growatt battery.

Evidence

  • Growatt Modbus RTU Protocol II V1.39 (the transcription in the manifest's
    upstream_docs), storage input registers: 1009-1010 Pdischarge1,
    "Discharge power", 0.1 W; 1011-1012 Pcharge1, "Charge power", 0.1 W.
  • Growatt-Local-Modbus storage_120.py (also in upstream_docs): register
    1009 is ATTR_DISCHARGE_POWER, 1011 is ATTR_CHARGE_POWER.

Change

  • drivers/lua/growatt.lua: read discharge from 1009 and charge from 1011.
    battery.w = charge - discharge as before, so charge is positive.
    Version 2.2.1.
  • drivers/tests/test_growatt_battery_sign.py: sets each register on its
    own and checks the sign. Both tests fail on main (+1800 W for a
    discharging battery, -2500 W for a charging one) and pass here.
  • drivers/tests/test_growatt_pv_only_battery.py: its battery fixture put
    the charge power at 1009, the old wrong address. It now puts it at 1011.
  • CHANGELOG, manifest and generated files.

Tests

  • make test-driver ID=growatt: 59 passed, 5 skipped.
  • make check: 5227 passed, 929 skipped.

Not verified on hardware

Nobody has checked this on a real Growatt. An owner can check it by
watching battery.w while the battery charges: it should be positive while
the SoC rises, and negative while the SoC falls.

Found on the way, not changed here

The same V1.39 table disagrees with the meter part of this driver:

  • 1015-1016 is Pactouser R, AC power to user on phase R only, not the
    total meter power.
  • 1021-1022 (PactouserTotal) and 1029-1030 (Pactogrid total) are powers
    in 0.1 W. The driver reads them as import and export energy in 0.1 kWh.
    V1.39 puts the energy totals at 1046-1047 (Etouser_total) and 1050-1051
    (Etogrid_total).

That needs its own issue and fix.

Refs #263

🤖 Generated with Claude Code

…2.1)

battery.w had the wrong sign: a charging battery showed as discharging
and the reverse. Growatt's Modbus RTU Protocol II V1.39 puts discharge
power (Pdischarge1) at input 1009-1010 and charge power (Pcharge1) at
1011-1012; Growatt-Local-Modbus maps them the same way. The driver now
reads them that way. A harness test sets each register on its own and
checks the sign. Not checked on hardware.

Refs #263

Signed-off-by: Fredrik Ahlgren <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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:09:28.642212Z e410a28 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.

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