Skip to content

feat(battery): report what deye, foxess_h3_smart, alphaess and kstar can do now - #253

Merged
frahlg merged 4 commits into
mainfrom
battery-limits-g3
Nov 22, 2026
Merged

frahlg merged 4 commits into
mainfrom
battery-limits-g3

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 FTW's order. This PR fills in the fields named in #250 for one group of drivers: deye, foxess_h3_smart, alphaess, kstar, atmoce, varta and ambibox. Four change; three have nothing documented to add.

Every new value is left out when its read fails or when it falls outside -40 to 100 °C or 0 to 100 kW. Reads and emits only: no control logic or writes changed. FoxESS still refuses a forced charge near full (srcfl/ftw#1993); that stays Core's to fix.

Refs #250

What each driver now reports

deye 2.2.0

Field / metric Register Source Confidence
available_charge_W, battery_charge_limit_a, battery_available_charge_w 212, U16, A × battery V (587, same poll) sunsynk three_phase_common.py ("BMS charging current limit"), ha-solarman deye_p3.yaml medium
available_discharge_W, battery_discharge_limit_a, battery_available_discharge_w 213, same same medium
temp_c (battery), battery_temp_c 217, (raw − 1000) / 10 already in the driver; sunsynk agrees high
temp_c (pv), inverter_temp_c 541, (raw − 1000) / 10 sunsynk and ha-solarman both apply the offset high
  • The limits are read only on three-phase hybrids (register 0 = 0x0005, 0x0500 or 0x0006) and only while register 111 (battery operation mode) reads 1, meaning the battery runs on its BMS. Both sources cover the three-phase map only. Register 111 is read once a minute. When it says there is no BMS, 217 is not read either.
  • Register 111 has its own retry rather than the driver's give-up-until-restart: a miss is tried again on the next poll, and after three in a row every 60 polls (five minutes at the 5 s poll). Timeouts at start-up no longer turn the limits off for good; a late answer turns them on. A unit that never answers costs one failed read per retry. 212/213 and 217 keep the driver's usual rule (three misses, then not until restart).
  • Bug fix: the driver read 541 as raw × 0.1 with no offset, so it reported the heatsink 100 °C too high. With the new range check those values would all have been dropped, so the offset is fixed here.
  • Fabricated zeros: a failed 217 or 541 read used to send 0 °C. Both are now left out. The invented-number baseline for deye drops from 28 to 26.
  • Unconfirmed: neither source says how often the BMS changes 212/213. I did not open Deye's own PDFs (MODBUS RTU V105.1 / V104.3, which ha-solarman cites). 218/219 ("BMS max charge/discharge current") are not read: no source says they are live. A BMS that loses its link while 111 still reads 1 may show 0 A, and Core would then read "may not charge".
  • The manifest lists single-phase models, but the driver reads the three-phase map everywhere. The new reads stay out of single-phase units (type 0x0003); the existing reads are unchanged and not checked here.

foxess_h3_smart 0.10.0

Field / metric Register Source Confidence
available_charge_W, battery_available_charge_w 46018-46019 (Pwr_limit_Bat_up), magnitude, W foxess_modbus remote_control_description.py; the driver already read it medium
temperature_C (range check added), battery_temp_c (new) 37611, i16 × 0.1 foxess_modbus high
battery_cell_temp_max_c / battery_cell_temp_min_c 37617 / 37618, i16 × 0.1 foxess_modbus _bms_entities (H3_PRO_SET, H3_SMART) medium
inverter_temp_c, pv temp_c (range check added) 39141 already there high
  • foxess_modbus describes 46018 as the most the battery accepts, BMS limits included. But this unit reads 0 there while an idle pack still charges when asked (the driver's CHARGE header has the hardware record). So a 0 is left out, which departs from the contract's "0 means not allowed now". The trade-off: sending the 0 would excuse a sleeping pack that could have followed; leaving it out means a cold or full pack that truly refuses charge also reads 0, the field is absent, and Core sees "unknown" rather than "limited". That case relates to FoxESS full-battery refusal is treated as device_fault / not_following (v0.163.0-beta.1) ftw#1993 (the refusal near full). foxess_bms_charge_limit_w still records every reading, zeros included.
  • No discharge limit is documented for this map (foxess_modbus has BMS rates only for H1/KH at 31025/31026), so available_discharge_W is not sent. 46607/46608 are owner settings and are not used.
  • 37617/37618 have not yet been seen answering on the 1K5. This device answers an unknown address with a timeout, so each is read on every sixth poll. After three misses in a row an address is asked again every 60 polls rather than given up until restart, so one comms outage does not turn them off for good. On a unit without them that is one timeout per address per retry.
  • 46018 is now read once at the top of the poll, not near the end. The control path reads it again, as before.

alphaess 1.2.0

Metric Register Source Confidence
battery_cell_temp_min_c 0x010D (269), i16 × 0.1 Alpha2MQTT Definitions.h, senalse/ha-alphaess-modbus register_map.md medium
battery_cell_temp_max_c 0x0110 (272), same same medium
  • No pack temperature exists in that block, so temperature_C is not sent.
  • senalse lists 0x010D/0x0110 as uint16 × 0.1; Alpha2MQTT reads them as signed. The driver decodes i16, which gives the same value at or above 0 °C and reads a sub-zero cell correctly.
  • 0x0111/0x0112 (BMS max charge/discharge current) are not read. Alpha2MQTT's author notes the charge value stays at 0 and the discharge value at twice the pack's rating. A 0 would tell Core the battery may not charge. The senalse map, on the other hand, lists 0x0111 as the BMS's present maximum charge current at × 0.1 A. The two sources disagree; settling it on hardware is a follow-up, not this PR.
  • Flag: evcc, Alpha2MQTT and senalse all put the grid meter at 0x0010-0x0021 and battery power at 0x0126. The driver's existing reads treat 0x0010-0x0028 as PV, battery and grid. That map needs its own check; this PR does not change it.

kstar 1.2.0

Field / metric Register Source Confidence
temperature_C, battery_temp_c input 3067, i16 × 0.1 ha-solarman kstar_hybrid.yaml (from KSTAR Hybrid Inverter Modbus V2.9.1) medium
inverter_temp_c input 3055, i16 × 0.1 same medium
  • Read as one input block, 3055-3067. 3056 is the battery converter's heatsink, not the battery, and is not used. The map has no live limit: 3078/3079 are percent settings.
  • Flag: KSTAR's map puts every reading in input registers from 3000. The driver's existing reads use holding registers 10-54. That needs its own check; this PR does not change it.

Nothing documented, unchanged

  • atmoce: evcc's template and the driver's register list show no temperature or live limit. 60318/60320 are settings and 60029 is the rating. I found no public copy of the vendor document the driver cites (Gateway Modbus Protocol V1.2).
  • varta: vartastorage and varta_modbus_hacs list no temperature. 1074/1075 are writable maximum-power settings, not live limits.
  • ambibox: I found no public MQTT topic list. The v2x fields chargePowerMax/dischargePowerMax are not documented as live.
  • None of the three sends a battery temperature, so there was no fabricated zero to remove.
  • No driver in this group documents grid headroom, so no available_import_W / available_export_W.

Tests

New Lua-harness tests, one file per driver: test_deye_battery_now.py (13), test_foxess_h3_smart_battery_now.py (8), test_alphaess_battery_now.py (3), test_kstar_battery_now.py (3). They cover scale and sign, a field and metric left out when its read fails, out-of-range values dropped, gating (Deye single-phase, no-BMS mode), read cadence, an absent register settling, and a register that answers late (Deye 111, FoxESS cell temperatures) coming back.

  • make test-driver ID=<id> for deye, foxess_h3_smart, alphaess and kstar: all pass.
  • make check (merged with main at c95f607): 5079 passed, 929 skipped.
  • make absent-register-report for deye and foxess_h3_smart: every address settles.

Not verified on hardware.

🤖 Generated with Claude Code

…can do now

Core will judge a battery against what it can do now, not only against
the order. These drivers now report the device's own temperature and
live limits where an open register map documents them, and leave a value
out when its read fails or it falls outside -40..100 C or 0..100 kW.

- deye 2.2.0: BMS charge/discharge current limits (212/213) as
  available_charge_W / available_discharge_W at the battery voltage read
  in the same poll, on three-phase hybrids whose battery runs on its BMS
  (register 111 = 1). Heatsink temperature (541) now takes off the 1000
  offset; it read 100 C too high. Failed temperature reads no longer send
  0 C.
- foxess_h3_smart 0.10.0: 46018 as available_charge_W when above 0 (an
  idle pack reads 0 and still charges). battery_temp_c metric, cell
  temperature range (37617/37618) every sixth poll.
- alphaess 1.2.0: cell temperature range (0x010D/0x0110) to history.
- kstar 1.2.0: battery temperature (input 3067) and inverter radiator
  temperature (input 3055).

Atmoce, Varta and Ambibox are unchanged: no documented temperature or
live limit, and no fabricated temperature to remove. Not verified on
hardware.

Refs #250

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Fredrik Ahlgren <[email protected]>
@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:20:34.437884Z 3f8b715 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 and others added 3 commits November 22, 2026 10:26
Review of #253:

- deye: register 111 had probe_read's give-up, so three early timeouts
  turned the BMS limits off until restart. It now has its own retry: the
  next poll after a miss, and every 60 polls after three in a row. A late
  answer turns the limits on.
- foxess_h3_smart: the cell temperatures (37617/37618) had the same
  give-up. Each now retries every 60 polls after three misses.
- foxess_h3_smart: the comment on 46018 now states the trade-off of
  leaving out a 0: a cold or full pack that truly refuses charge reads 0,
  the field is absent, and Core sees "unknown" rather than "limited".
- alphaess: note that senalse lists the cell temperatures as uint16 and
  0x0111 as a present BMS limit, against Alpha2MQTT.

Refs #250

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Fredrik Ahlgren <[email protected]>
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]>
Signed-off-by: Fredrik Ahlgren <[email protected]>

# Conflicts:
#	SUPPORT_STATUS.md
#	drivers/tests/invented-number-baseline.json
@frahlg
frahlg merged commit 217ebc0 into main Nov 22, 2026
5 checks passed
@frahlg
frahlg deleted the battery-limits-g3 branch November 22, 2026 09:37
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