Repository navigation
feat(ev): offer a declined car current again within the plug-in - #2084
Merged
Merged
Conversation
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. |
A car that stopped asking for current stayed out of the plan until it was unplugged. While it stays plugged in with a goal to meet, Core now ends that refusal an hour after it formed, or when a new goal window starts, at most once an hour. A car that is full or at its own limit declines again and the latch re-forms after 90 s. No retry for a met goal, a car whose fresh reading is Complete or at its limit, a passed one-time deadline, a charger Core may not command, or while Charge now holds. The plan replans when a refusal forms and when it ends, so a retry costs one short offer. Decision: Fredrik, 25 November 2026. Refs #2080 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Fredrik Ahlgren <[email protected]>
The retry now disarms the charging.interrupted notice, whose stop is the one before the car declined. An Easee that takes minutes to start after the retry no longer turns that hour-old stop into "Charging stopped early". A new steady run arms it again. The control check the retry asks moves into chargerControlAllowed so a test can drive it with a real registry. New tests cover the notice, the hold guard for Stop and Charge now, the dispatch gates, observe-only and read-only drivers, and a full car retried through a night with no not_following state and no charging.interrupted. Refs #2080 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Fredrik Ahlgren <[email protected]>
frahlg
force-pushed
the
decline-retry-2080
branch
from
November 25, 2026 15:41
67ff721 to
e5074ca
Compare
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.
Refs #2080. Stacked on #2082 (base
fix-2080); retarget tomasterbefore #2082 merges.Decision (Fredrik): FTW offers a car that declined current again later in the same plug-in, with a time bound.
Rule
A car that stops asking for current while Core offers it latches
charging_declinedafter 90 s (unchanged), and the plan leaves it out. While the car stays plugged in, Core ends that latch once, and the plan takes the car in again:DeclineRetryInterval(1 hour) after the car declined, orCore ends a latch at most once per interval, so a car that always declines is offered current at most once an hour, deadline rolls included. A car that is full or at its own limit declines again, and the latch re-forms after the usual 90 s. The plan then decides when the offer comes, as for any planned car.
The retry also disarms the "Charging stopped early" notice (
charging.interrupted). The run before the refusal ended with the car declining; without this, an Easee that takes minutes to start after the retry would report that hour-old stop as an interruption. A new steady run arms the notice again.No retry when:
Completeor at its charge limit;Registry.CanControl, throughchargerControlAllowed; an approved OCPP charger counts), disabled, offline, or dispatch is held (the check runs after the controller's existing gates);Unplug, a higher goal, Charge now, measured charging, a corrected level, and a vehicle-limit car reporting
Chargingstill clear the latch at once.The plan also follows the latch's edges at once. A new edge check beside the EV-stop replan requests a replan when the latch forms (
loadpoint_declined) and when it ends while plugged in (loadpoint_decline_ended). Before, the old plan kept offering a declining car, or held back a car that may charge, until the next scheduled replan. That bounds the cost of a retry to one short offer.Why an hour
A retry against a car that is full or at its own limit costs the 90 s refusal window, plus the charger's start delay (Easee: up to about 5 min at 6 A, per the driver's start-boost note) and two replans. An hour keeps that under a tenth of the time.
An hour is also longer than both the Easee start delay and
LoadBalancerRaiseWait(15 min, #2050), so one retry has ended before the next can begin. Neither is affected: the retry only runs while Core holds the charger at 0 A. The latch re-forms only on the car's own refusal (Easee reason 50 or op mode 4), never on a load-balancer hold, which keepsrequest_activetrue.And an hour is short enough that a car that paused on its own (a timer in the car, a cold battery) loses at most an hour of a night's charging.
What the owner sees
While latched: "Car not taking power" (
vehicle_not_requesting, #2082). During a retry: the normal offer verdicts (waiting for response, thenvehicle_declinedif the car refuses for 90 s, or charging). No new reason names, settings or UI.A full car retried through a night raises no notice:
vehicle_declinedcomes beforeno_power_response, and the latch re-forms at 90 s (pinned in a test below). A charger that never delivers while the car keeps asking may raise "Not following" about once an hour. That is a real fault, as at any other start, and stays reported.Tests
New in
go/internal/loadpoint/controller_decline_retry_test.go. The rig runs the controller tick, schedule roll and a planner stand-in that, like Core's, leaves out a declined car. The car refuses offers, and the charger reports the car as asking under Core's 0 A, as an Easee does.TestDeclinedCarIsOfferedAgainAfterTheRetryInterval: latched at 0 W withvehicle_not_requestinguntil the interval passes, then planned and offered again.TestDeclinedCarIsOfferedAgainAtTheNextRecurringDeadline: the deadline roll brings an offer less than an interval after the refusal.TestCarThatKeepsDecliningIsNotFlapped: five hours of refusals with a deadline roll in between give 4–5 offers, each at least an hour apart.TestDeclinedCarRetryNeedsAGoalStillToMeet: retries for an unmet goal. No retry when the goal is lowered below the level, the car is at its own limit or reportsComplete, a one-time deadline passed, or Core may not command the charger.TestDeclineExitsStillActAtOnce: Charge now and unplug still clear the latch at once.TestRetryDoesNotReportAnOldStopAsAnInterruption: a steady run, a refusal, then a retry where the car asks at 0 W for ten minutes gives nocharging.interrupted. It failed before the fix (one event).TestDeclinedCarIsNotRetriedUnderAHold: Stop, run for over an hour, keeps the latch; the guard holds for Stop and Charge now. Removing the guard fails all three rows.TestDeclinedCarIsNotRetriedWithoutDispatch: an offline charger, a driver not running, and held dispatch are never retried. Moving the retry ahead of the gates fails the offline and dispatch rows.TestDeclineEdgesReplan(go/cmd/ftw): replans on the latch forming and ending, not on unplug.TestDeclineRetryFollowsTheRegistrysControlAuthority(go/cmd/ftw): a real registry and controller. An observe-only or read-only driver is never retried; a controlled one is, after the interval.TestFullCarRetriedThroughANightRaisesNoNotice(go/internal/api): the real controller, latch and retry, and the control states thecontrol.not_followingrule reads. A car charges, becomes full, and refuses every offer for nine hours. No tick showsnot_following, nocharging.interruptedfires, there are 7 to 9 offers, and the verdict between retries isvehicle_not_requesting. Run with the charger reporting the car as asking under 0 A, and not.On the base branch, with a stub for the two new names, the first three tests fail and the "goal not met" row fails. The guard rows and the exit tests pass there, as they should. On this branch all pass.
go test ./internal/loadpoint/ ./internal/mpc/ ./internal/api/ ./internal/control/ ./cmd/ftw/: all ok.GOFLAGS=-p=4 make verify: vet, tests (88 packages ok) and build clean, on the review fixes too. One earlier run hit a port already in use in an OCPP test (TestLuaEaseeWebsocketStaysPendingAndDoesNotReceiveCurrent, another run on the same machine); it passed alone three times and in the next full run.No scenario in
go/test/sitecovers a declining car today, so this PR adds none there.Changeset:
minor. This is a visible change in charging behaviour, approved by Fredrik.🤖 Generated with Claude Code