Repository navigation
feat(drivers): report what the battery can do now (GoodWe, Solis, Sofar, SolaX, SAJ, Growatt, Solinteg) - #262
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| -- 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") |
There was a problem hiding this comment.
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 👍 / 👎.
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]>
5cb6db6 to
40bcb13
Compare
…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]>
40bcb13 to
f0ec1e9
Compare
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:
available_charge_W/available_discharge_Wonly with a battery voltage from the same poll. No fresh voltage, or 0 V, means no watts.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.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.temp_c,battery_temp_cavailable_charge_W/available_discharge_Winverter_temp_cTemperatures 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.wthat 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.
available_charge_W/available_discharge_Wtemp_cinverter_temp_c,pv.temp_cThe 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.
available_charge_W/available_discharge_Wtemperature_Cinverter_temp_cFixed: 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_cmay 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.available_discharge_W/available_charge_Wtemperature_C, now range-checked, plusbattery_temp_cinverter_temp_cThe 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.
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.inverter_temp_c.growatt 2.2.0
Source: Growatt Modbus RTU Protocol II V1.39 (transcription); Growatt-Local-Modbus and homeassistant-solax-modbus agree for SPH.
temp_c, no longer 0 on a failed read.inverter_temp_c.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.whas the wrong sign.test_growatt_pv_only_battery.pyencodes 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.
temperature_C, only with a pack voltage (30254) in the same poll.inverter_temp_c;pv.temperature_Cno longer 0 on a failed read.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.jsonshrinks: goodwe 24→23, solis 27→25, sofar 21→20, solax 15→14, solinteg 27→25 (the temperatures no longer invent a number).make bump-driver, newupstream_docsfor 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 intest_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).make test-driver ID=<id>for goodwe, solis, sofar, solax, saj, growatt, solinteg: all pass.make check: 5225 passed, 929 skipped, on head f0ec1e9 (rebased onto main after feat(svk): report what the battery can do now (Solis 50-125k, Konja) #252, feat(battery): report what deye, foxess_h3_smart, alphaess and kstar can do now #253, feat(victron_mqtt, victron, ferroamp_modbus, zap): what the battery can do now #254, feat(huawei, sma, fronius, kostal, sigenergy): report what the battery can do now #259 and fix(svk): skip the self-heal when the battery read fails (0.2.5, 0.1.14) #261).Not verified on hardware. All values in the tests are synthetic.
Refs #250
🤖 Generated with Claude Code