Repository navigation
feat(huawei, sma, fronius, kostal, sigenergy): report what the battery can do now - #259
Merged
Merged
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. |
frahlg
added a commit
that referenced
this pull request
Nov 22, 2026
…e the caveats Review of #259. - huawei: a SUN2000 with no LUNA2000 may answer 37001/37004 with 0, so that answer does not prove a battery. The temperature (37022) and the limits (37046/37048) are now read only once energy storage unit 1 reports a rated charge or discharge power above 0 (37007/37009, U32 W). Otherwise 0 W would read as "may not charge now". The finding is kept for the run; until then it is read on each poll the battery answers. Tests cover a unit that answers 0, a rating that does not answer, and one rating above 0. - huawei: CHANGELOG, manifest and code say plainly that 37046/37048 are not shown to be live on hardware, and that only unit 1 is read. - kostal: the code comment says that taking register 5 as the word order of every Float is unverified on hardware, that a wrong order gives plausible but wrong values, and that the learned order and battery type hold until a driver restart. Refs #250 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Fredrik Ahlgren <[email protected]>
frahlg
force-pushed
the
battery-limits-g1
branch
from
November 22, 2026 09:41
f0ca186 to
c8ad7a8
Compare
…y can do now
Core will judge a battery against what the device says it can do now
(docs/WRITING-A-DRIVER.md, "What a battery can do now"). Each driver now
reports what its vendor documents, and leaves out what did not answer.
- huawei 2.2.0: available_charge_W/available_discharge_W from 37046/37048
("[Energy storage] Maximum charge/discharge power", U32 W). Huawei does
not say how fast they follow the BMS.
- kostal 2.2.0: temperature_C from 0xD6 and available_* from 0x434/0x436,
"Maximum charge/discharge power limit (read-out from battery)", Floats
in the word order register 0x05 reports, read only when 0x24C shows a
battery.
- sigenergy 1.2.0: available_* from plant 30047/30049 ("[ESS] Available
max charging/discharging power") and temperature_C from 30286 (average
cell temperature), read only when the ESS answered.
- sma 2.2.0, huawei, kostal: battery and inverter temperatures are left
out when the read fails, is NaN or is outside -40..100 C, instead of 0.
- fronius 2.2.0: the inverter temperature comes from TmpCab (40109).
40111 is TmpSnk, which Fronius marks not supported, so it sent 0 C.
SMA and Fronius document no live charge or discharge limit, so they send
none. No driver documents grid import/export headroom. Metrics follow the
same rules. No control path, write or command changed. Not checked on
hardware.
Refs #250
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Fredrik Ahlgren <[email protected]>
…e the caveats Review of #259. - huawei: a SUN2000 with no LUNA2000 may answer 37001/37004 with 0, so that answer does not prove a battery. The temperature (37022) and the limits (37046/37048) are now read only once energy storage unit 1 reports a rated charge or discharge power above 0 (37007/37009, U32 W). Otherwise 0 W would read as "may not charge now". The finding is kept for the run; until then it is read on each poll the battery answers. Tests cover a unit that answers 0, a rating that does not answer, and one rating above 0. - huawei: CHANGELOG, manifest and code say plainly that 37046/37048 are not shown to be live on hardware, and that only unit 1 is read. - kostal: the code comment says that taking register 5 as the word order of every Float is unverified on hardware, that a wrong order gives plausible but wrong values, and that the learned order and battery type hold until a driver restart. Refs #250 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Fredrik Ahlgren <[email protected]>
frahlg
force-pushed
the
battery-limits-g1
branch
from
November 22, 2026 09:49
c8ad7a8 to
b1a56b3
Compare
This was referenced Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Core will judge a battery against what the device says it can do now (docs/WRITING-A-DRIVER.md, "What a battery can do now", #250). This PR fills that in for five drivers: huawei, sma, fronius, kostal and sigenergy. Each reports only what its vendor documents, and leaves out a value whose read failed, which is NaN, or which falls outside -40 to 100 °C or 0 to 100 kW. The same values go to history (
battery_temp_c,battery_available_charge_w,battery_available_discharge_w,inverter_temp_c). No control path, write or command changed.Per driver
huawei 2.2.0
available_charge_Wavailable_discharge_Wtemp_c(kept)inverter_temp_c(fixed)upstream_docs.kostal 2.2.0
temperature_Cavailable_charge_Wavailable_discharge_Winverter_temp_c(fixed)sigenergy 1.2.0
available_charge_Wavailable_discharge_Wtemperature_Cavailable_import_W/available_export_W.upstream_docspoints at the vendor PDF in TypQxQ/Sigenergy-Local-Modbus (markedvolatile), because Sigenergy's download page refuses direct fetches.sma 2.2.0: fabricated-zero fix only
temp_cfrom 30849 "Battery temperature" andinverter_temp_cfrom 30953 "Internal temperature" (S32, TEMP format) are now left out when the read fails or answers NaN. They used to be sent as 0 °C. Source: SMA Modbus TI for Sunny Boy / Sunny Tripower, version 1.4.upstream_docsnames SMA-Modbus-TI-en-10, which is hosted there.fronius 2.2.0: fabricated-zero fix only
Found while reading, not changed here
w,vandsocare likely wrong on a GEN24 with storage. This needs its own fix; there is a NOTE in the driver.decode_f32_bejoins both words into one 32-bit number. That flips the sign on a Lua build with 32-bit integers, which the test interpreter is ("Numbers" in WRITING-A-DRIVER.md). The new temperature decoder works on the 16-bit halves; the old one is unchanged.device_statenot added. Huawei (37000 running status) and Sigenergy (30051 plant running state) could report it later. It was outside this task.Tests
drivers/tests/test_{huawei,sma,fronius,kostal,sigenergy}_battery_now.py. Each covers:make test-driver ID=<id>passed for all five.make absent-register-reportsettles for every new register.make check: 5101 passed, 929 skipped.drivers/tests/invented-number-baseline.jsonshrinks: fronius 11 to 10, kostal 22 to 21, sma 28 to 26.Not verified on hardware. FTW's bundled copies of huawei, sma, fronius and kostal do not move with this PR. Bump the pin and run
scripts/sync-bundled-drivers.sh.Refs #250
🤖 Generated with Claude Code