Repository navigation
feat(sungrow): report what the battery can do now (1.7.0) - #251
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
force-pushed
the
sungrow-battery-limits
branch
from
November 22, 2026 09:16
edf3710 to
f551a36
Compare
Read the pack temperature (documented 13025), the BMS's max charge and discharge current (5635/5636) and map the running state the driver already reads (13000) to device_state. Emit temperature_C, available_charge_W, available_discharge_W (amps times this poll's battery voltage) and device_state on the battery blob, plus the battery_* metrics from docs/WRITING-A-DRIVER.md. The two new reads run on the full poll only. Fast polls carry the last values only while the battery read succeeds; a failed read leaves its field out. Out-of-range values and Sungrow's "not available" values are dropped. Running-state values are matched whole, as Appendix 2 of Sungrow's protocol V1.1.9 lists them. No available_import_W: the protocol has no register for it. 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]>
…edges Cite the owner's box beside NOT_RUNNING and in the test header: in all 14 standby episodes the state went 0x0800 -> 0x0008 -> 0x0020 -> 0x0800, with 0x0010 in 3 of them. Test that device_state leaves when a later full poll reads 0x0800 or 0x0040. Compare the battery temperature in the register's tenths, so -40.0 and 100.0 stay in on any float width, and test both edges. Say in the CHANGELOG and the manifest notes that whether 5635/5636 follow the BMS live is unconfirmed on hardware. Refs #250 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Fredrik Ahlgren <[email protected]>
frahlg
force-pushed
the
sungrow-battery-limits
branch
from
November 22, 2026 09:18
f551a36 to
4f7951f
Compare
This was referenced Nov 22, 2026
frahlg
added a commit
that referenced
this pull request
Nov 22, 2026
Keep both CHANGELOG entries (this group and sungrow 1.7.0 from #251) and regenerate index.yaml, devices.yaml and the support status. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Fredrik Ahlgren <[email protected]>
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.
Why
FTW Core marks a battery "not following" when it gives less than ordered. On the owner's SH-RT with an SBR096 pack, 30 days show device limits, not lost control:
Core will learn these limits. First the driver reports what the device says, using the contract in #250 (docs/WRITING-A-DRIVER.md, "What a battery can do now").
What changes
On the
batteryblob:temperature_Cavailable_charge_Wavailable_discharge_Wdevice_state"standby"for 0x0008, 0x1400, 0x0010, 0x1200;"starting"for 0x0020, 0x1600; left out otherwiseMetrics on full polls, each only when its value is present:
battery_temp_c,battery_charge_limit_a,battery_discharge_limit_a,battery_available_charge_w,battery_available_discharge_w.optional_read, so a model that refuses them stops being asked after three refusals. An SG string inverter never asks.Sources and confidence
Sources: Sungrow's "Communication Protocol of Residential Hybrid Inverter" V1.1.9 (2025-06-20), read from a third-party copy; mkaiser/Sungrow-SHx-Inverter-Modbus-Home-Assistant
modbus_sungrow.yaml; bohdan-s/SunGatherregisters-sungrow.yaml. Read for addresses only; no code copied.available_*. The CHANGELOG and the SH-RT, SH-RS and SH-T notes in the manifest say this is unconfirmed on hardware.set_device_faultpath.The protocol PDF asks not to be put on public sites, and Sungrow does not host it at a URL the watcher can fetch, so
upstream_docsis unchanged. The driver comment names the document and version.Grid import limit: not found
No
available_import_W. Neither V1.1.9 nor mkaiser nor SunGather has a register for import headroom, a purchase limit or a grid charge limit. What I found:What to check on hardware
Not verified on hardware. On the owner's box, during a short forced discharge: if
battery_discharge_limit_areads about 22 A, 5636 is a live BMS limit. If it stays at a rating (for example 30 A), it is not, andavailable_*should come out. Also check thatdevice_statereadsstandbythenstartingin the next standby event.Tests
drivers/tests/test_sungrow_battery_limits.py, 39 cases: scale and sign (25.3 °C, -5.0 °C, 24 A × 208 V = 4992 W, 22 A = 4576 W, positive while discharging); 0 A gives 0 W; each field and metric absent when its read fails, for a refusal and a timeout; temperature edges (-40.0 and 100.0 kept, -40.1 and 100.1 dropped), out-of-range temperature, 0xFFFF amps, over 100 kW and 0 V or 0xFFFF V dropped;device_statefor each standby and starting code, absent for running, forced, external EMS, 0x0014 and 0x0041, and when the running state fails; the field's full episode (0x0800, 0x0008, 0x0020, then 0x0800 or 0x0040 on successive full polls) withdevice_stateleaving on the poll that reads running; carried on fast polls; watts follow the fresh voltage; a failed full read or failed battery read clears the carried values; a refused register is given up after three full polls; an SG string inverter never asks. 20 of them fail against 1.6.1.test_sungrow_poll_cadence.py: the full poll now also reads 13024 and 5634; fast polls are unchanged.make test-driver ID=sungrow: 153 passed, 4 skipped.make check: 5052 passed, 929 skipped.Stacked on #250
device_stateis not an allowed battery field on main until #250 merges, so this branch sits onbattery-limits-contract(6e4f526) and shows #250's two commits. I will rebase onto main once #250 merges.FTW's bundled copy does not move with this PR. Bump the pin and run
scripts/sync-bundled-drivers.sh.Refs #250
🤖 Generated with Claude Code