Repository navigation
feat(etrel, keba, schrack_ev): control the charging current; wallbox says it cannot - #244
Conversation
…says it cannot
Etrel INCH, KEBA KeContact P30 and Schrack i-CHARGE CION Home/Semipublic now
declare capabilities = { "ev" }, emit ev and take ev_set_current, ev_pause,
ev_resume and ev_start, so FTW can use them as loadpoints. Each register map
now comes from the vendor's own document; the old maps were in none.
Orders become a current per phase within Core's max and cap per phase and the
charger's own limit, rounded down, and 0 below 6 A. Default mode stands the
charger down once and settles. A refused write returns false.
Wallbox publishes no local Modbus interface for its chargers. The driver
declares read_only = true and points to FTW's OCPP central system.
All four are experimental: not yet confirmed on hardware.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
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: 7383808588
ℹ️ 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".
| for _, key in ipairs({ "max_amps_per_phase", "cap_amps_per_phase" }) do | ||
| local v = cmd[key] | ||
| if finite_positive(v) and v < ceiling then ceiling = v end |
There was a problem hiding this comment.
Honor zero-valued current caps
When Core supplies a positive power order with cap_amps_per_phase = 0, finite_positive(v) discards the cap instead of stopping charging. In the Lua harness, an 11,040 W order with a zero cap writes 16 A and enables charging. The same predicate appears in KEBA's and Schrack's amps_for implementations, so all three drivers can exceed Core's explicit current ceiling. Treat a finite zero cap as binding and route it through the existing below-minimum stop behavior.
AGENTS.md reference: AGENTS.md:L39-L42
Useful? React with 👍 / 👎.
| if written_auth and auth and auth ~= written_auth and | ||
| written_auth_ms and now - written_auth_ms >= ORDER_SETTLE_MS then | ||
| written_auth = nil |
There was a problem hiding this comment.
Preserve authorization intent when detecting stalled commands
If the charger clears register 100 to zero after accepting an authorization, this branch clears written_auth after 10 seconds. However, the stalled-command check below requires written_auth == 1 continuously for 30 seconds, so it resets its timer before it can report the dropped authorization. Reproducing a connected car with authorization held at zero leaves command_stalled false beyond 40 seconds. Track the requested authorization independently of the write-deduplication cache so invalidating that cache does not erase the intent needed for stall detection.
Useful? React with 👍 / 👎.
…ase only when certain Core runs driver_default_mode at every start. The stand-down now acts only after a command wrote in this run, so a charger FTW never steered keeps its own state and a charge already running goes on. The heishamon 0.8.1 rule. Once FTW wrote, the stand-down is unchanged and still settles. An order is divided by one phase only when config says the installation is one-phase and the car has not drawn on more than one, or when Core orders 1p and the car draws on exactly one. Otherwise, idle or just started too, it is three, so a three-phase car never gets a one-phase sum on each phase. Schrack measures no phases and uses only config phases. Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in #242. The generated files regenerate unchanged. Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-down, failsafe and phases - Resume and start come without a budget. Write an order back only when it is under 30 s old; otherwise 6 A, and only when the last limit Core named allows it. With no such limit, write nothing and return false. KEBA and Schrack write the 6 A current before the enable or authorisation. - Default mode returns true only when the stand-down is confirmed, or when FTW wrote nothing in this run. A refused stand-down returns false and is tried again at most once a minute, with no write in between. - KEBA refreshes the failsafe timeout while FTW steers, paused or not, and after three refusals tries once a minute instead of stopping. - KEBA counts phases only when all three phase currents answered in that poll, and tries a lost phase current again once a minute. - A charger that holds a charge paused against the order for 30 s (Etrel status 6, KEBA state 5) gets the setpoint or enable again on the next order, at most every 30 s. - Schrack clears a void authorisation once per void episode. - Wallbox: say we found no documented local Modbus interface, and that its power and energy readings are unverified. Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in #247. The generated files regenerate unchanged. Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er stand-down - Schrack: a void authorisation is reset at most every 30 s while the charger calls it void, not once per episode. A fault made the reset void again at once, and void then stayed set after the fault cleared, so the driver never reset again. The reset counts only once its write lands. - Resume uses the limit named with the last positive order. Core names cap_amps_per_phase only with a positive order, so a 0 W order no longer replaces it with the site maximum. - Resume or start with no known limit, after a reload for example, writes nothing and returns true, logging once that the charger waits for Core's next order. Nothing was refused and nothing written above the budget. - KEBA keeps refreshing the failsafe timeout while FTW holds the charger disabled after a stand-down. Whether the failsafe current overrides a disable once FTW stops is not verified; the header says so. Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Summary
Fredrik decided on 21 November 2026 that a driver that can command its device ships with control on, and one that cannot says so plainly (#239). Etrel, KEBA, Schrack and Wallbox were community sketches: no
DRIVERblock, nodriver_command,v2x_chargeroutput and register maps from no vendor document. Core uses a charger as a loadpoint only whenDRIVER.capabilitiesholds"ev", so FTW could not use any of them.etrel1.1.0keba1.1.0schrack_ev1.1.0wallbox1.1.0read_only = trueEvery controlling driver:
power_winto amps per phase:power_w / (voltage × phases). Phases is one only when config saysphases: 1and the car has not drawn on more than one phase since it was plugged in, or when Core orders1pand the car draws on exactly one. Otherwise it is three, idle or just started too, so a three-phase car never gets the L1 sum Core budgeted for a 1p order. Schrack measures no phases, so it uses onlyphasesfrom config (default 3).max_amps_per_phase,cap_amps_per_phaseor the charger's own limit (Etrel 1028, KEBA 1110, Schrack 127 and cable 128), and rounds down to 0.1 A (Schrack: 1 A). Below 6 A it writes 0 A or disables. It never rounds up.ev_resumeandev_start, which carry no budget, writes an order back only when it is under 30 s old. Otherwise it writes 6 A (KEBA and Schrack write the current before the enable or authorisation), and only when the limit named with the last positive order allows 6 A; a 0 W order carries no cap and does not replace it. With a limit below 6 A it writes nothing and returns false. With no limit known, after a reload for example, it writes nothing, returns true and logs once that the charger waits for Core's next order.max_a, its ceiling asdevice_limit_awith age, andcurrent_limit_a,reason_no_current_labelandcommand_stalledfrom device state.Old maps that were wrong:
Driver evidence
etrel,keba,schrack_ev,wallboxetrel.goandkeba-modbus.gowere read for behaviour only. No code was copied.Safety
wis positive while charging.Control evidence
experimental.New Lua harness tests (
drivers/tests/lua_harness/test_{etrel,keba,schrack_ev}_control.lua, run by pytest) cover three default-mode calls on a fresh driver writing nothing, a refused stand-down returning false and retried at most once a minute, resume of an old order (6 A only, or nothing without room), the KEBA failsafe refresh during a pause and its back-off, the KEBA phase count with L2 and L3 unreadable, re-writing a stalled order, the Schrack void reset at most every 30 s (including a fault that clears while void still reads 1, and a refused reset), a 1p order on an idle three-phase installation giving P/(3·V), P/V only for a car drawing on exactly one phase or a configured one-phase installation, power-to-amps mapping with caps, rounding down, the 6 A minimum, write only on change, pause and resume, default mode settling, a refused write returning false, refusal settling, and re-asserting a lost order. KEBA also covers a non-P30 product code and the failsafe refresh. Schrack also covers a void authorisation and a car that is not plugged in.make refused-write-report: etrel, keba and schrack_evSETTLED 1 WRITES 0,0,0,0,0,0,0,0, since the probe never commands and default mode now leaves an unsteered charger alone. The control tests cover a refused stand-down after a command wrote (1,0,0,0, then one retry a minute). Wallbox has no default mode.Checks
Signed-off-by.make test-driver ID=<id>for all four: pass.make check: 4996 passed, 933 skipped (on main with fix: read-only EV drivers say why, drop two that read nothing #241, feat(chargers): current-limit control for alfen, abb_terra and mennekes (1.1.0) #242 and fix(zaptec_cloud): stand down only after FTW wrote a current (0.2.1) #243).The four drivers leave
drivers/tests/invented-number-baseline.json. Generated files (index.yaml,devices.yaml,support-status.json,SUPPORT_STATUS.md) will conflict with the other charger-control PRs and need regenerating at merge.🤖 Generated with Claude Code