Skip to content

feat(ev): offer a declined car current again within the plug-in - #2084

Merged
frahlg merged 2 commits into
masterfrom
decline-retry-2080
Nov 27, 2026
Merged

frahlg merged 2 commits into
masterfrom
decline-retry-2080

Conversation

@frahlg

@frahlg frahlg commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Refs #2080. Stacked on #2082 (base fix-2080); retarget to master before #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_declined after 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:

  • one DeclineRetryInterval (1 hour) after the car declined, or
  • when a new goal window starts: the recurring deadline rolled, or the owner set another deadline.

Core 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:

  • the goal is met: the level reaches the planning target, or a vehicle-limit goal is complete;
  • the car's own fresh reading is Complete or at its charge limit;
  • a one-time deadline has passed (a vehicle-limit goal stays due, as before);
  • the charger is observe-only or read-only (Registry.CanControl, through chargerControlAllowed; an approved OCPP charger counts), disabled, offline, or dispatch is held (the check runs after the controller's existing gates);
  • a manual hold is active, Stop as well as Charge now. Stop keeps the charger at 0 A for the owner, and Charge now already clears the latch at once.

Unplug, a higher goal, Charge now, measured charging, a corrected level, and a vehicle-limit car reporting Charging still 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 keeps request_active true.

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, then vehicle_declined if 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_declined comes before no_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 with vehicle_not_requesting until 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 reports Complete, 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 no charging.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 the control.not_following rule reads. A car charges, becomes full, and refuses every offer for nine hours. No tick shows not_following, no charging.interrupted fires, there are 7 to 9 offers, and the verdict between retries is vehicle_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/site covers 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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T07:57:15.519971Z 228236f PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@frahlg
frahlg changed the base branch from fix-2080 to master November 25, 2026 15:39
frahlg and others added 2 commits November 25, 2026 16:39
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
frahlg force-pushed the decline-retry-2080 branch from 67ff721 to e5074ca Compare November 25, 2026 15:41
@frahlg
frahlg merged commit e703091 into master Nov 27, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant