Skip to content

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

Open
frahlg wants to merge 1 commit into
fix-2080from
decline-retry-2080
Open

frahlg wants to merge 1 commit into
fix-2080from
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.

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; an approved OCPP charger counts), disabled, offline, or dispatch is held (the check runs after the controller's existing gates);
  • Charge now is active (it 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.

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.
  • TestDeclineEdgesReplan (go/cmd/ftw): replans on the latch forming and ending, not on unplug.

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. 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

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 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
@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.

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