Skip to content

feat(drivers): report what the battery can do now (GoodWe, Solis, Sofar, SolaX, SAJ, Growatt, Solinteg) - #262

Merged
frahlg merged 2 commits into
mainfrom
battery-limits-g2
Nov 22, 2026
Merged

frahlg merged 2 commits into
mainfrom
battery-limits-g2

Conversation

@frahlg

@frahlg frahlg commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What this does

Core marks a battery "not following" when it gives less than ordered. On a real site most of those warnings were device limits, not lost control. Core will judge against what the battery can do now, so these seven drivers now report the device's own figures where its register map documents them (docs/WRITING-A-DRIVER.md, "What a battery can do now").

The rules, in every driver here:

  • A BMS current limit becomes available_charge_W / available_discharge_W only with a battery voltage from the same poll. No fresh voltage, or 0 V, means no watts.
  • A temperature outside -40..100 °C or a power outside 0..100 kW is dropped. A read that fails is left out, never sent as 0.
  • The same numbers go to history: battery_temp_c, battery_available_charge_w, battery_available_discharge_w, battery_charge_limit_a, battery_discharge_limit_a, battery_cell_temp_max_c, battery_cell_temp_min_c, inverter_temp_c.
  • Reads and emits only. No write, mode or control path changed.

No driver here reports available_import_W / available_export_W: none of the maps has a live grid headroom figure (only configured limits).

Per driver

goodwe 2.2.0

Source: GoodWe, Modbus Protocol Hybrid for Energy Storage Inverters, 2 Feb 2024 (PDF); the goodwe library (goodwe/et.py) agrees.

Register Meaning Reported as Confidence
35180 battery 1 voltage, U16 × 0.1 V voltage for the watts high
35184 battery 1 mode, 0 = no battery gate: BMS block read only when ≠ 0 high
37000-37023 "BMS Operation Data", one read as the goodwe library does
37011 battery protocol, codes in GoodWe's Table 8-33 gate: block used only when it names a BMS (not 0, 0x11F "EMS Battery" = no direct link, or 0xFFFF) high
37003 BMS pack temperature, × 0.1 °C temp_c, battery_temp_c high
37004 / 37005 max BMS charge / discharge current, A available_charge_W / available_discharge_W high (from the BMS block)
37020 / 37021 max / min cell temperature, × 0.1 °C cell metrics high
35176 heat sink temperature, S16 × 0.1 °C inverter_temp_c high

Temperatures are decoded signed, and 0xFFFF / 0x7FFF are dropped as "no value", as the goodwe library does.

A non-zero battery mode says a battery is there, not that a BMS talks to the inverter. Without one the block answers zeros, so the 37011 gate keeps 0 °C and 0 W out. A BMS that talks and allows 0 A still sends 0 W.

Fixed: earlier releases sent register 35183 as the battery temperature (0 °C when it failed). GoodWe's map gives 35183 to the low word of battery power.

Found, not changed (#264): GoodWe's map disagrees with the driver's other reads. 35178 is the BUS voltage (driver: battery V), 35179 the NBUS voltage (driver: battery A), 35180 the battery voltage (driver: battery W), 35182-35183 battery power S32 (driver: SoC at 35182), 35105 PV1 power (driver: PV total), 35109 PV2 power (driver: PV2 V/A), 35113 PV3 power (driver: grid Hz). This PR leaves those reads alone; #264 tracks them. Until #264 is fixed, Core will compare a battery.w that is probably wrong (the driver reads 35180, the battery voltage register, as watts) with these correct limits. goodwe is read-only, so Core sends it no orders, but any judgement of that pack against its limits is unsound until then.

solis 2.2.0

Source: Solis RS485_MODBUS RTU Hybrid Inverter Protocol (translated 15 Sep 2020, public copy); hn/ginlong-solis, Pho3niX90/solis_modbus and homeassistant-solax-modbus agree.

Register Meaning Reported as Confidence
33143 / 33144 battery charge / discharge current limitation, U16 × 0.1 A, "(From BMS)" available_charge_W / available_discharge_W high
33133 battery voltage, U16 × 0.1 V (existing read) voltage for the watts high
33160 current battery model, 0 = no battery model gate: limits used only when it names a battery maker high for the codes in Solis's map; medium for the rest
33096 lead-acid battery temperature, S16 × 0.1 °C (existing read) temp_c see below
33093 inverter temperature (existing read) inverter_temp_c, pv.temp_c high

The limits are read as one block, 33143-33160, and count only while 33160 names a battery maker, so a lead-acid or BMS-less battery (which reports 0 A) sends nothing. Solis's map gives 0 "no battery model", 2 / 0x0200 "User define" and maker codes. Pho3niX90/solis_modbus lists more makers and puts the generic and lead-acid choices at LV 99-103 and HV 0x6300. The rule: LV 1-98 except 2, or HV 0x0100-0x6200 with a zero low byte except 0x0200. An unknown code sends no limit, never 0 W.

33096 is the inverter's probe for a lead-acid battery, not a value from a BMS. Without the probe it reads 200.2 °C (reported in Pho3niX90/solis_modbus issue 186, on an S6-EH1P with a Dyness pack); the range check now drops that. 43130/43131, which the driver writes itself, are not used as limits.

Not used: 33043 "Battery Temperature (BMS)" (Pho3niX90 only, from protocol V3.2). The 2020 map has it reserved, and it read 0.0 on that same S6-EH1P, which would look like a cold battery. 34350/34351 cell temperatures: one source, added there on 18 November 2026.

solax 1.2.0

Source: SolaX Energy Storage Inverter Modbus TCP&RTU Communication protocols V3.28, X1/X3 Hybrid G4 (public copy); homeassistant-solax-modbus agrees for Gen3 to Gen6.

Register Meaning Reported as Confidence
0x0024 / 0x0025 BMS charge / discharge max current, U16 × 0.1 A, "(real time)" available_charge_W / available_discharge_W high
0x0014 battery voltage, × 0.1 V (existing read) voltage for the watts high
0x0018 battery temperature, int16, 1 °C temperature_C high
0x0008 radiator temperature, int16, 1 °C inverter_temp_c high for G4

Fixed: the driver scaled 0x0018 by 0.1, so 25 °C showed as 2.5 °C.

Unconfirmed: homeassistant-solax-modbus reads 0x0008 in tenths on some X3 Gen5/Gen6 units. The driver has no generation check and follows the G4 map its manifest lists, so inverter_temp_c may read ten times high there. It is history only; the code comment says so.

saj 1.3.0

Source: stanus74/home-assistant-saj-h2-modbus (modbus_readers.py, register_overview.md). SAJ's own H2 protocol is behind its portal.

Register Meaning Reported as Confidence
0xA036 / 0xA037 BatDisCurrLimit / BatChaCurrLimit, U16 × 0.1 A available_discharge_W / available_charge_W medium, liveness unconfirmed
0xA00E battery 1 voltage, × 0.1 V (existing read) voltage for the watts high
0xA010 battery 1 temperature (existing) temperature_C, now range-checked, plus battery_temp_c high
0x4010 SinkTemp, I16 × 0.1 °C inverter_temp_c medium

The two limits sit at the end of the 0xA000 BMS block, beside the BMS's charge voltage and cut-off voltage, and apart from the charge current the owner sets at 0x4026. That reads as what the BMS allows now, but the source does not say so in words. This needs a capture that shows them move with temperature or SoC. They are read only while BatNum / BatOnline say a pack is there.

sofar 2.2.0

Source: SofarSolar Modbus Communication Protocol V1.2, 2 Dec 2020 (public copy); homeassistant-solax-modbus agrees.

  • 0x0607 Temperature_Env_Bat1, I16, 1 °C (existing read) → temp_c, only when it answered and 0x0604 reports a pack voltage. Sofar calls it "battery ambient temperature" and does not say whether it comes from the BMS.
  • 0x041A Temperature_HeatSink1, I16, 1 °C → inverter_temp_c.
  • No limits: the map has no live BMS limit. 0x104B / 0x104C are BatConfig settings the installer writes; the 0x9000 pack block needs a write to select a pack.

growatt 2.2.0

Source: Growatt Modbus RTU Protocol II V1.39 (transcription); Growatt-Local-Modbus and homeassistant-solax-modbus agree for SPH.

  • 1040 battery temperature, 0.1 °C (existing read) → temp_c, no longer 0 on a failed read.
  • 1114 / 1115 max / min cell temperature, 0.1 °C → cell metrics, only while a battery is detected.
  • 93 Temp1, inverter temperature, 0.1 °C → inverter_temp_c.
  • No limits: the BMS block has one BMS_MaxCurr (1090) for charge and discharge together, with no documented unit.

Found, not changed: all three sources put discharge power at 1009-1010 and charge power at 1011-1012. The driver reads them the other way round, so battery.w has the wrong sign. test_growatt_pv_only_battery.py encodes the current reading. This needs its own PR.

solinteg 1.2.0

Source: M-TEC Energy Butler RTU Protocol GEN2 + GEN3 V1.0 (public copy, a rebadged Solinteg); croedel/MTECmqtt and homeassistant-solax-modbus.

  • 33003 battery temperature, 0.1 °C (existing read) → temperature_C, only with a pack voltage (30254) in the same poll.
  • 33009 / 33011 max / min cell temperature, U16, 0.1 °C → cell metrics (two community sources).
  • 11032 inverter temperature sensor 1, I16, 0.1 °C (existing read) → inverter_temp_c; pv.temperature_C no longer 0 on a failed read.
  • No limits: homeassistant-solax-modbus lists charge / discharge limits at 33021 / 33023 with a note that they may be at 32005 / 32006. That is too unsure for a live limit on a driver Core controls; a wrong register reading 0 would tell Core the battery may not charge. Solinteg's own table (V00.22, named in the driver) would settle it.

Drivers with nothing documented

No live charge or discharge limit is documented for sofar, growatt or solinteg (reasons above). They get the temperature work and the fabricated-zero fix only.

Also in this PR

  • invented-number-baseline.json shrinks: goodwe 24→23, solis 27→25, sofar 21→20, solax 15→14, solinteg 27→25 (the temperatures no longer invent a number).
  • Manifests: minor bumps with make bump-driver, new upstream_docs for every driver (all URLs answered 200), and the stale one-line changelogs on goodwe, saj and growatt replaced.

Tests

New harness tests per driver (drivers/tests/test_<id>_battery_now.py, and new cases in test_saj.py). Each covers: fields present with the right scale and sign, a 0 A limit sent as 0 W, fields and metrics absent when the read fails or there is no fresh voltage, and out-of-range values dropped. goodwe also covers mode 1 with an all-zero block and protocols 0 / 0x11F / 0xFFFF (nothing sent), and a talking BMS with 0 A (0 W sent). solis covers maker codes (limits sent) and no battery, User define, lead-acid, generic and unknown codes (nothing sent).

Not verified on hardware. All values in the tests are synthetic.

Refs #250

🤖 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-22T09:38:36.826619Z 5cb6db6 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5cb6db622f

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread drivers/lua/goodwe.lua
-- below are read only while the mode says a battery is connected; a
-- PV-only install answers the BMS block with zeros, and 0 C or 0 W
-- would read as a cold battery that may not charge.
local b1_regs = probe_read(35180, 5, "holding")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Track the new block read separately from the single-register read

If the five-register request fails while the existing single-register read at 35180 succeeds, this optional probe never settles: probe_read keys its failure counter only by address, and the earlier probe_read(35180, 1, "holding") clears that counter on every poll. A Lua-harness reproduction with the single-register request succeeding and the block request rejected produced 10 failed block requests across 10 polls instead of stopping after three. This leaves a persistent failed read in every poll, which the driver's probing contract explicitly warns can cause the host watchdog to take otherwise working telemetry offline. Key probe state by address, count and kind, or consolidate the overlapping reads.

Useful? React with 👍 / 👎.

frahlg added a commit that referenced this pull request Nov 22, 2026
Review of #262. A non-zero battery mode or voltage says a battery is
there, not that a BMS talks to the inverter. A lead-acid or BMS-less
pack answers zeros, and 0 C and 0 W read as a cold battery that may not
charge.

- goodwe: use the 37000 block only while 37011 (battery protocol,
  GoodWe Table 8-33) names a BMS: not 0, not 0x11F "EMS Battery" (no
  direct link) and not 0xFFFF. A talking BMS that allows 0 A still
  sends 0 W.
- solis: read 33143-33160 in one read and use the limits only while the
  battery model at 33160 names a maker (Solis map, plus the generic and
  lead-acid codes from Pho3niX90/solis_modbus); an unknown code sends
  nothing.
- Comments: solax 0x0008 may read in tenths on X3 Gen5/Gen6 (history
  only); solis 33096 is the lead-acid probe, not a BMS value; goodwe
  points at #264 for its other reads.

Refs #250

Signed-off-by: Fredrik Ahlgren <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
frahlg and others added 2 commits November 22, 2026 10:53
…ar, SolaX, SAJ, Growatt, Solinteg)

Core marks a battery "not following" when it gives less than ordered.
Most such warnings on a real site were device limits, so Core will judge
against what the battery can do now. These seven drivers now report the
device's own figures where its map documents them:

- goodwe 2.2.0: BMS pack temperature, charge and discharge current
  limits (37003-37005) as watts at the 35180 battery voltage, cell
  temperature extremes and the heat sink temperature. The old battery
  temperature read 35183, which GoodWe's map gives to battery power.
- solis 2.2.0: BMS current limits 33143/33144 as watts. The lead-acid
  probe's 200.2 C "no probe" value is dropped.
- solax 1.2.0: BMS max currents 0x0024/0x0025 as watts, radiator
  temperature, and the battery temperature in whole degrees (it was
  scaled by 0.1).
- saj 1.3.0: BMS current limits 0xA036/0xA037 as watts (liveness not
  stated by the source) and the heat sink temperature.
- sofar 2.2.0, growatt 2.2.0, solinteg 1.2.0: battery, cell and
  inverter temperatures; no documented live limit, so no watts.

A failed read is left out, never sent as 0; temperatures outside
-40..100 C and powers outside 0..100 kW are dropped. Reads and emits
only; no control path changes. Not verified on hardware.

Refs #250

Signed-off-by: Fredrik Ahlgren <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of #262. A non-zero battery mode or voltage says a battery is
there, not that a BMS talks to the inverter. A lead-acid or BMS-less
pack answers zeros, and 0 C and 0 W read as a cold battery that may not
charge.

- goodwe: use the 37000 block only while 37011 (battery protocol,
  GoodWe Table 8-33) names a BMS: not 0, not 0x11F "EMS Battery" (no
  direct link) and not 0xFFFF. A talking BMS that allows 0 A still
  sends 0 W.
- solis: read 33143-33160 in one read and use the limits only while the
  battery model at 33160 names a maker (Solis map, plus the generic and
  lead-acid codes from Pho3niX90/solis_modbus); an unknown code sends
  nothing.
- Comments: solax 0x0008 may read in tenths on X3 Gen5/Gen6 (history
  only); solis 33096 is the lead-acid probe, not a BMS value; goodwe
  points at #264 for its other reads.

Refs #250

Signed-off-by: Fredrik Ahlgren <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@frahlg
frahlg merged commit 36d0160 into main Nov 22, 2026
5 checks passed
@frahlg
frahlg deleted the battery-limits-g2 branch November 22, 2026 09:57
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