Skip to content

feat(svk): report what the battery can do now (Solis 50-125k, Konja) - #252

Merged
frahlg merged 3 commits into
mainfrom
battery-limits-g5
Nov 22, 2026
Merged

frahlg merged 3 commits into
mainfrom
battery-limits-g5

Conversation

@frahlg

@frahlg frahlg commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Core will judge a battery against what it can do now, not only against the order (#250). This PR brings four SvK drivers in line with that contract: the three Solis 50-125 kW drivers and the Konja MG-261. It changes reads and emits only. Control, slew, self-heal and writes stay as they were. The Solis drivers keep main's 60 s cadence for the limit block and add two small temperature reads on that same poll.

Refs #250

Solis: 50-125k-svk 0.3.0, 50-125k-svk-slew 0.2.0, 50-125k-svk-ac-slew 0.3.0

The three drivers share the same poll code, so each gets the same change.

Field / metric Register Scale Confidence
battery.available_charge_W, metric battery_available_charge_w 25012-25013 (parallel), else 25004-25005 (this unit) U32, 1 W address and scale: high. Live: medium, see below
battery.available_discharge_W, metric battery_available_discharge_w 25014-25015, else 25006-25007 U32, 1 W same
inverter.available_import_W 25016-25017, else 25008-25009 U32, 1 W same
inverter.available_export_W 25018-25019, else 25010-25011 U32, 1 W same
battery.temperature_C, metric battery_temp_c middle of 34350 and 34351 S16, 0.1 °C medium, not verified on hardware
metrics battery_cell_temp_min_c / battery_cell_temp_max_c 34350 / 34351 S16, 0.1 °C same
metric inverter_temp_c 33093, inverter module S16, 0.1 °C same

What changed:

  • No resend after a failed read. The 16-register read of 25004-25019 stays as on main: one read on poll 1, then every 12th poll (about 60 s at the 5 s poll). A value is held until the next read. A read that fails now clears it; earlier versions sent the last values again for as long as the block stayed silent.
  • Bounds. A value above 1000 kW (these are 50-125 kW units), such as the 0xFFFFFFFF not-present value, is left out. 0 W is kept: it means "not allowed now".
  • Temperatures, new. On the same poll as the limit block (poll 1, then every 12th), one 2-register read at 34350 and one 1-register read at 33093: two small reads a minute more on the 9600-baud bus. temperature_C is the middle of the coldest and hottest cell, sent only when both answer and lie in -40 to 100 °C. The inverter module gets -40 to 150 °C, since power electronics derate above 100 °C. A failed read leaves them out; a value is held only until the next read. The two reads go through the drivers' existing bundle_read, so a register a unit lacks stops costing a failed read every minute.
  • Metrics battery_available_charge_w, battery_available_discharge_w, battery_temp_c, battery_cell_temp_min_c, battery_cell_temp_max_c and inverter_temp_c, on each read.
  • Fabricated zeros. A SoC that did not answer was sent as SoC_nom_fract = 0. It is now left out, and so is the Wh headroom when there is no SoC or no configured capacity.

Same source as before: the parallel-system figure first, then this unit's (par_avail_* or avail_* on main). A read never left the parallel value empty, so in practice the drivers send 25012-25019. This unit's own registers, 25004-25011, exist and would match battery.W (34755, this unit's battery) more closely. Blixt L1 feeds inverter.available_import_W / available_export_W into its arbitrator clamp, so switching is a decision for the Solis site owners, not part of this PR. Both sets are logged once at the first read to help with that decision.

Source: the driver already read 25004-25019. The temperature addresses, and the meaning of all of them, come from the vendor documents cited by the full solis_50_125k.lua driver these drivers were cut down from (Blixt gateway history, commit d95e07f): Solis RS485_MODBUS ESINV-33000ID Hybrid (2021-12-28, under NDA) and the "50~125K FCR Application" sheet of Solis's "Modbus Register usage scheme of Application Scenarios" (Ver 20260304/20260310). I could not read either; neither is public, so they are named in a code comment rather than in upstream_docs.

Not confirmed: the notes on hand do not say outright that 25004-25019 follow the BMS live. They are read-only (FC04) registers in the Remote Control block, next to 25003, whose bits flag a BMS, inverter or grid limit. That suggests figures the inverter works out, not settings, but nobody has confirmed it. The temperature addresses are also unverified on hardware, and which battery (Batt1 or both) 34350/34351 cover is not stated.

Konja: konja-261-svk 0.4.0

No new reads. Everything comes from the BMS and PCS blocks the driver already reads every poll.

Field / metric Register Scale Confidence
battery.temperature_C, metric battery_temp_c BMS 2750, average temperature int16, 0.1 °C high (driver's existing decode)
battery.available_charge_W, metric battery_available_charge_w BMS 2758-2759 uint32, 0.1 kW address: high. Live: medium
battery.available_discharge_W, metric battery_available_discharge_w BMS 2760-2761 uint32, 0.1 kW same
forbid gate (unchanged) BMS 2755: 0x55 / 0xCC / 0xAA sets that direction to 0 W high
metric inverter_temp_c (and the existing inverter.heatsink_C) PCS 8059, IGBT int16, 0.1 °C high

Source: Konja 261_EMS_Protocol_V116 - PCS - EN.xlsx (V1.16), as already decoded in the driver. I did not have the workbook itself.

What changed:

  • The limits were module-level and stayed after a failed BMS read, so the last values went out again. They are now this poll's values or nothing.
  • Metrics go out once every 10 s. At the 20 Hz poll, every poll would be 80 history rows a second.
  • Battery W was sent as 0 W when the PCS block failed. It is now left out. The control path keeps its own 0 fallback, unchanged.
  • A SoC that never answered is no longer 0 %, and the Wh headroom is left out without SoC or capacity.

Not confirmed: 2758-2761 are read-only values in the BMS block, and the forbid flag next to them is clearly live. But the workbook rows quoted in the driver do not say that the powers follow temperature and SoC. No grid headroom is reported: no row the driver decodes gives one. PCS 8255/8256 and EMS 304/306 are settings and are not used.

Bounds: battery temperature -40 to 100 °C; IGBT temperature -40 to 150 °C, because power electronics derate above 100 °C and a 100 °C cut would hide the reading that explains a derate; power 0 to 1000 kW. The raw 0.1 kW count is checked before scaling, so a 32-bit Lua build cannot wrap a large value back into range.

Found, not changed here

The Solis self-heal does math.abs(bat_w) (and bat_w - slew_committed_w in the slew drivers) while control is on. If 34755 fails, that raises an error. It is control logic, so it gets its own PR.

Tests

  • New drivers/tests/lua_harness/test_battery_limits_solis_svk.lua (run once for each Solis driver) and test_battery_limits_konja.lua, wrapped by drivers/tests/test_battery_limits_svk.py. Solis: the parallel figure first, with fallback to this unit's only when it is missing; 0 W kept; temperatures with the right scale and sign, below zero included; the limit block and both temperature reads on poll 1 and poll 12 and none between, with values held; fields and metrics cleared after a failed read that follows a good one, and back after recovery; a failed limit block keeps the temperatures and the reverse; out-of-range values dropped at and just past each bound; no 0 % SoC or Wh headroom without a SoC. Konja: scale and sign; the forbid gate; the 10 s metric rate; fields cleared after a failed BMS read; no 0 W battery power without a PCS reading; bounds at and just past each limit. Both scripts fail on origin/main's drivers.
  • make test-driver ID=50-125k-svk, ID=50-125k-svk-slew, ID=50-125k-svk-ac-slew, ID=konja-261-svk: all pass.
  • Absent-register and invented-number probes: all four clean.
  • make check: 5079 passed, 929 skipped (rebased on main after docs: what a battery can do now (temperature, available power, device state) #250, feat(sungrow): report what the battery can do now (1.7.0) #251 and feat(victron_mqtt, victron, ferroamp_modbus, zap): what the battery can do now #254).
  • Konja driver_poll upvalues stay under LuaJIT's 60 (46 counted by luac 5.5, which includes _ENV).

Not verified on hardware.

🤖 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:19:22.327713Z 48ff31b 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.

frahlg added a commit that referenced this pull request Nov 22, 2026
With control on, a failed battery-power read (34755) made the Solis
self-heal raise: math.abs(nil) in 50-125k-svk, nil - committed in
50-125k-svk-slew. The whole poll failed, so one missed read cost all
telemetry for that poll. The check now skips a poll with no battery
reading and starts its count again. With a reading it works as before.
50-125k-svk-ac-slew already checked its AC reading. Not checked on
hardware.

Refs #252

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Fredrik Ahlgren <[email protected]>
frahlg added a commit that referenced this pull request Nov 22, 2026
…14) (#261)

With control on, a failed battery-power read (34755) made the Solis
self-heal raise: math.abs(nil) in 50-125k-svk, nil - committed in
50-125k-svk-slew. The whole poll failed, so one missed read cost all
telemetry for that poll. The check now skips a poll with no battery
reading and starts its count again. With a reading it works as before.
50-125k-svk-ac-slew already checked its AC reading. Not checked on
hardware.

Refs #252

Signed-off-by: Fredrik Ahlgren <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
frahlg and others added 3 commits November 22, 2026 10:42
Core will judge a battery against what it can do now, not only against
the order. These four SvK drivers now report their live limits without
resending old ones, so a device limit is not taken for lost control.

Solis 50-125k-svk 0.3.0, 50-125k-svk-slew 0.2.0, 50-125k-svk-ac-slew
0.3.0: available power keeps its source (parallel system first, then
this unit) and its 60 s read. A failed read now clears the values
instead of resending them. Out-of-range values are dropped, and the
limits go to history as metrics. Switching to this unit's registers and
reading temperatures are left for the site owners and hardware evidence.

Konja konja-261-svk 0.4.0: temperature_C and available power from this
poll's BMS block only, so a failed read no longer replays old limits.
Metrics once every 10 s, not at the 20 Hz poll. No new reads.

All four drop out-of-range values and no longer send a missing SoC as
0 %. Control, slew and writes are unchanged. Not checked on hardware.

Refs #250

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Fredrik Ahlgren <[email protected]>
34350/34351 (min/max cell temperature) give temperature_C as their
middle plus the cell min/max metrics, and 33093 gives inverter_temp_c.
Both are read with the 25004 limit block, on poll 1 and then every 12th
poll: two small reads a minute. A failed read leaves them out; a value
is held only until the next read. The addresses come from the full Blixt
Solis driver (d95e07f), which cites Solis documents we could not read,
and are not yet verified on hardware.

Refs #250

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