Repository navigation
fix(control): sync PI.Setpoint when energy-dispatch zeros GridTargetW - #84
Merged
Merged
Conversation
The energy-dispatch branch in ComputeDispatch was setting GridTargetW=0 via direct assignment and calling PI.Reset() (which only zeros the integral, not the setpoint). Result: if the operator later left a planner mode — e.g. via POST /api/mode — the legacy PI path would compute error against a stale PI.Setpoint while deadband/error checks used GridTargetW=0. Under those conditions the controller could issue no correction when one was needed (or the wrong correction). Use SetGridTarget(0) so both fields move in lockstep. This mirrors every other caller in the package. Regression test pre-poisons PI.Setpoint + GridTargetW to 3000, runs one energy-dispatch cycle, and asserts both are 0 afterward. Caught by Codex on PR #79. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
frahlg
added a commit
that referenced
this pull request
Nov 17, 2026
The worker keeps a battery that may not cover the car out of the car's import room (srcfl/energyplan#83 for the library, #84 for the fleet model that plans every request where a car can charge), the rule Core enforces since #2023. The binaries are byte-identical to the ones Energyplan's local CI tested on 55118a38, which has the same tree as 7ea7d998. A native test plans the field night with the bundled worker and needs Core to accept the plan. With the bundle it replaces (847936a) Core rejects the plan in slot 0. Signed-off-by: Fredrik Ahlgren <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Addresses the P1 Codex raised on #79 — #79 (comment)...
What was wrong
The energy-dispatch branch in
ComputeDispatchzeroedGridTargetWwith a direct assignment and calledPI.Reset()(which only clears the integral, not the setpoint). If the operator later left a planner mode, the legacy PI path would computeerror = PI.Setpoint - gridWagainst a stale setpoint while deadband / error checks used the syncedGridTargetW=0. Result: the controller could issue no correction when one was needed, or the wrong correction, until another explicitSetGridTargetcall happened.Fix
One-liner:
state.GridTargetW = 0→state.SetGridTarget(0). The helper updates both fields in lockstep, same pattern as every other caller in the package.Test
Pre-poisons
PI.Setpoint + GridTargetW = 3000, runs one energy-dispatch cycle, asserts both are 0 afterward. Fails cleanly before the fix, passes after.Test plan
go test ./...).🤖 Generated with Claude Code