Repository navigation
fix(control): a battery boost makes the battery cover the boosted car - #2012
erikarenhill wants to merge 2 commits into
Conversation
A boost was only a permission: in planner arbitrage or cheap modes an idle or charging slot kept the battery at zero, or charging, while the boosted car drew from the grid. While the charger reports the car drawing and a battery is above the boost's reserve, the battery now discharges at least to grid zero for the house and that car, never exporting for car draw the meter no longer shows. A plan that discharges further keeps its target. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0124SQZZwXFRjnTEvh4SNrjp Signed-off-by: Erik <[email protected]>
After the boosted car slowed or stopped, the reactive controller eased the battery down from the boost's discharge by about 1 kW a tick, exporting the rest for up to a minute. During a boost and for 30 s after the car stops, a planner mode's reactive path now goes straight to its grid target. The live EV reading also ends the boost's cover a tick before the loadpoint's copy. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0124SQZZwXFRjnTEvh4SNrjp Signed-off-by: Erik <[email protected]>
frahlg
left a comment
There was a problem hiding this comment.
Reviewed and tested. The tests are real: copied onto master, TestBatteryBoostCoversCarWhatTheSlotSays and the first leg of TestBatteryBoostFollowsTheCarBothWays fail there and pass here. A five-mode scratch matrix (self_consumption and the four planner modes, energy and legacy paths, idle/charge/discharge slots, car rising, steady, slowing, stopped, at reserve) projected no grid export below 0 W in any boosted case, and the only golden behaviour change is seeded_ev_boost/043. The full make verify passes on master with this PR merged.
One thing to change before merge:
- No-export modes lose their margin during a boost. planner_self, planner_cheap and planner_passive_arbitrage must never sell (
batteryMayNotExport). The reactive path lifts their target tomax(GridTargetW, GridToleranceW)for that reason (#1969). The cover aims at exactly grid zero (boostTotal = currentTotal - gridW, around dispatch.go 2231–2253), so with meter and charger lag those modes can export for a few seconds while a boost runs. Please use the tolerance-lifted target in those modes and add a test for them; the current tests cover only planner_arbitrage.
Smaller, your call:
- The "car stopped" leg of
TestBatteryBoostFollowsTheCarBothWaysaccepts −501…0 W and also passes on master. - Both tests set
SlewRateW = 100000, so slew is not exercised. - Regenerating the whole golden file adds about 1e-6 W of float noise to unrelated records; re-recording only 043 would keep the diff to the one change.
boostCoveris true when any one battery qualifies, so a sibling battery at its reserve also has its planned grid charge held back (then clamped, so no export).
frahlg
left a comment
There was a problem hiding this comment.
Claude's review, posted at Fredrik's request. Read together with #2011.
This looks right.
- The battery stops at grid zero from the meter, so it never exports for car power the meter no longer shows. The reserve, the battery's limits and the fuse guard still apply after it.
- A boost now beats a planned cheap grid charge (golden
seeded_ev_boost/043: +5 kW → −3.2 kW). That is a product change, and it matches what the owner asked for when they started the boost. - The description says a plan that discharges further keeps its target. That holds on the energy path. On the reactive planner path the battery goes straight to the plan's grid target during the boost, as the code comment says. Worth a word in the description.
- The other hunks in the golden file are float noise under a watt from re-recording; only 043 changes.
boostCoverUntilis set insideComputeDispatch.main.gois its only caller outside tests, so nothing else extends the hold.- There is no hysteresis at the 100 W threshold, but the 30 s hold covers a reading that flickers.
Checked locally with #2011 merged in: the same go vet and go test as there pass.
miravoss26
left a comment
There was a problem hiding this comment.
Battery boost now covers the house plus the boosted car down to grid zero, lifts the plan's no-discharge rails while it does, and holds grid-zero for 30 s after the car stops so the battery drops to the house at once.
- Read the dispatch.go diff in full.
stateis a pointer, soboostCoverUntilpersists across ticks.boostCoverneeds a battery online, not discharge-blocked, with SoC above the reserve, so a battery at the reserve falls back to the plan. boostCoverskipsapplyPlanSignFloor, but reserve clamp, limits, owner floor and the fuse guard still run afterwards. That is what I'd want here.- Nit: during the 30 s hold a planner mode's reactive path ignores plan charge intent. It reads intended, and the comment says so. Worth a test for a boost ending exactly at a plan charge slot, if one isn't there already.
- CI green, golden file updated.
Safe to merge from my read. Dispatch logic, so a human who knows the control loop should still sign off.
What changed
While a battery boost is active, the charger reports the boosted car drawing (
BatteryBoostEVChargingWabove 100 W), and an online battery is above the boost's reserve,ComputeDispatchnow:currentTotal − gridW).gridWalready leaves out car draw the boost does not cover.planHasNonDischargeIntentand the plan/exec sign floor. A battery manual hold already lifts them the same way.The reserve clamp, battery limits, owner floor and the fuse guard still apply after this.
Second commit: the battery follows the car down as fast as it follows it up.
Why
In
planner_arbitrage, a boost was only a permission. On a live site the car drew 8.25 kW with the boost active, while an idle slot kept the battery at 0 W and a later charge slot charged it at +1.8 kW from the grid. The planner kept the battery for the evening's higher prices, which made the owner's "Boost for 1 h" do nothing. The UI tells the owner "Let the home battery feed the car for a while", and that is what this does.Boundaries and safety
seeded_ev_boost/043, planner_cheap, cheap slot, +5 kW grid charge → −3.2 kW, projected grid 8157 W → 0 W. That record is re-recorded; no other golden file changes.Verification
TestBatteryBoostFollowsTheCarBothWays: car 8 kW → 5 kW → stopped, over three ticks. It fails on the first commit (−7550 W instead of −5500 W when the car slows) and passes here. The second commit changes no golden record.TestBatteryBoostCoversCarWhatTheSlotSayscovers idle and charge slots in arbitrage: no boost, boost with the car drawing, and the car stopped while the charger still reports it. It fails on master (idle slot gives 0 W) and passes here.go test ./internal/control ./internal/loadpoint ./cmd/ftw ./internal/mpc,go vet ./internal/control.Stopping the car with the second commit (same site):
The battery now reacts within one tick of the charger's report. The export that remains, about 10 s, is Easee Cloud's reporting delay. With the first commit alone, the same stop left the battery easing down for about 50 s and exporting about 6 kW for 20–30 s.
Performance
A throwaway benchmark of
ComputeDispatchon an arbitrage idle slot with a boosted car, 5 runs each, same machine:No measurable change.
Overlap
Draft #1789 (fuse protection as one function) rewrites parts of
dispatch.goand touchesseeded_ev_boost.json. It has conflicted with master since 27 Oct, so this PR is based on master. The change is one block after the path switch plus twoboostCoverchecks.Related: the boost was also stopped by a binding fuse. That is fixed separately in #2011.
Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_0124SQZZwXFRjnTEvh4SNrjp