Repository navigation
fix(control): a battery that may not export holds the grid above 0 W - #1969
Merged
Merged
Conversation
In planner_self, planner_cheap and passive arbitrage the reactive path aimed a discharging battery at 0 W with a symmetric dead band. Each drop in house load then sold battery energy until the next correction, about as often as the site imported. While such a battery discharges more than the dead band, the target is now at least grid_tolerance_w, so the band ends at 0 W. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the reading The bias keyed on the battery's measured power, so an idle battery under a legacy plan with a negative grid target discharged toward it for one tick and exported. It now applies whenever the plain target would have the battery discharge more than the dead band. Charging from PV surplus no longer sees the bias at all. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis 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. |
6 tasks done
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.
Problem
A field report on 0.158.0, planner_passive_arbitrage with battery export not allowed, a 20 kWh battery as site meter and no PV: while the battery covered about 2.4 kW of house load, the meter showed 100–270 W of export in 315 of 721 minutes, worst −1 387 W, mostly 16–19 h. The battery followed its order (−2 571 W against −2 575 W requested); the order itself was too large.
In planner modes the reactive path aims at a grid target of 0 W: passive arbitrage cover-load and idle slots call
SetGridTarget(0), planner_self chases 0 W, and stale plans fall back to 0 W.site.grid_target_wdoes not apply there. The dead band (grid_tolerance_w, 42 W by default) is symmetric, and the meter clamp lands each correction on the target. So every drop in house load sold battery energy until the next correction, about as often as the site imported. With a larger tolerance a steady export inside the band was never corrected. Thetolerance_win control_feedback (about 10 % of the request) is only the display's "on target" band; it steers nothing.Export from the battery is sold at spot and bought back later at the full price. Import while the battery discharges stays in the battery for later.
Change
Mode.batteryMayNotExportnames planner_self, planner_cheap and planner_passive_arbitrage. In the reactive PI path, when the plain target would have such a battery discharge more than the dead band (currentTotal − errW < −grid_tolerance_w), the target is at least+grid_tolerance_w. The dead band then ends at 0 W.The cost: while it discharges, the site settles about
grid_tolerance_wabove 0 W, and from idle the battery leaves import below 2 ×grid_tolerance_wuncovered. At the default 42 W that is a small steady import; a site with a large tolerance imports more, and a smaller tolerance narrows it. A discharge smaller than the tolerance can still export up to its own size.Evidence
no_export_band_test.go:TestPlannerSelfIdleGateLeavesExistingDischargeAloneInsideDeadbandnow seeds a 20 W import, inside the new band; its point, that the idle gate leaves a discharge alone, is unchanged.seeded_planner/045_planner_cheapmoves 855 W: a legacy plan of −1 365 W had the battery discharge toward export, and it now stops at +60 W. The other five families only picked up re-dump noise (0→-0, float jitter) and keep master's files.make verifypasses on this machine.Review
An independent review (Sonnet) walked every path to this code for the three modes: passive cover-load and idle slots, planner_self, planner_cheap with and without a slot directive, the legacy plan target, stale-plan fallbacks, the EV surplus-only reserve, manual holds, and the fuse and import-ceiling rails after the PI. It confirmed that the bias never enlarges a discharge, that a switch to PV charge imports at most the tolerance for one tick, that the swapped PI setpoint is restored, and that loads between one and two tolerances settle without a limit cycle.
It found no blocking issue. Changed from it (6e2c18b): the first version keyed the bias on the battery's reading, so an idle battery under a negative legacy plan exported for one tick before the bias engaged. The bias now keys on the planned discharge, with a regression test.
Left as it is: the bias is not capped below the tolerance. A site with a 200 W tolerance holds 0–400 W import while discharging. The mode promises no battery export, so the band's lower edge stays at 0 W; such a site can lower its tolerance.
🤖 Generated with Claude Code