From 4e4151cb4c40ea7eef707eedcaa672425a8a00a7 Mon Sep 17 00:00:00 2001 From: Fredrik Ahlgren Date: Wed, 25 Nov 2026 08:34:00 +0100 Subject: [PATCH 1/2] fix(ev): name a declined car's stop instead of an empty plan A car that stopped asking for current while the plan offered it latches charging_declined after 90 s, and the planner leaves it out for the session. The controller then named its 0 W no_plan_budget, and under Core's own 0 A the charger reports the car as asking again, so the feedback read as a plan that chose not to charge a car that wanted it. Name that stop vehicle_not_requesting, the reason Core already gives the same latch on vehicle-limit goals. Planning, dispatch and the latch's exits are unchanged. Refs srcfl/ftw#2080 Co-Authored-By: Claude Opus 5.5 Signed-off-by: Fredrik Ahlgren --- .changeset/declined-car-not-empty-plan.md | 10 ++++ go/internal/api/api_vehicle_stopped_test.go | 22 +++++---- go/internal/loadpoint/controller.go | 6 +++ .../controller_commanded_reason_test.go | 48 +++++++++++++++++++ 4 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 .changeset/declined-car-not-empty-plan.md diff --git a/.changeset/declined-car-not-empty-plan.md b/.changeset/declined-car-not-empty-plan.md new file mode 100644 index 000000000..dbc4399a0 --- /dev/null +++ b/.changeset/declined-car-not-empty-plan.md @@ -0,0 +1,10 @@ +--- +"ftw": patch +--- + +A car that stopped asking for charge while FTW offered it now reads "Car not +taking power" instead of "Waiting for the plan". The plan leaves such a car +out for the rest of the session, so the old text blamed an empty plan for a +stop the car made. Nothing else changes: unplugging, a higher goal or Charge +now still lets FTW offer current again, and the battery level is never +guessed from the stop. diff --git a/go/internal/api/api_vehicle_stopped_test.go b/go/internal/api/api_vehicle_stopped_test.go index 570a164c0..4ecf0c3ee 100644 --- a/go/internal/api/api_vehicle_stopped_test.go +++ b/go/internal/api/api_vehicle_stopped_test.go @@ -105,16 +105,20 @@ func TestVehicleStopBlipKeepsFailedStartVerdict(t *testing.T) { } // Core's own 0 W stop for a car that stopped asking is Core in control. +// Under that 0 A an Easee reports the car as asking again (srcfl/ftw#2080); +// the verdict stays Core's stop either way. func TestCoreStopForANotRequestingCarIsFollowing(t *testing.T) { - synctest.Test(t, func(t *testing.T) { - e := &vehicleStopTrace{evTrace: newEVTrace(0), stopped: true} - for range 60 / 5 { - e.tick(0, "vehicle_not_requesting") - } - if f := e.verdict(t); f.Reason != "vehicle_not_requesting" || f.Status != "following" || f.Evidence != "measured" { - t.Fatalf("Core's own stop: %+v", f) - } - }) + for _, stopped := range []bool{true, false} { + synctest.Test(t, func(t *testing.T) { + e := &vehicleStopTrace{evTrace: newEVTrace(0), stopped: stopped} + for range 60 / 5 { + e.tick(0, "vehicle_not_requesting") + } + if f := e.verdict(t); f.Reason != "vehicle_not_requesting" || f.Status != "following" || f.Evidence != "measured" { + t.Fatalf("Core's own stop, charger says stopped=%v: %+v", stopped, f) + } + }) + } } func TestVehicleStopNeverOverridesStaleFailedOrContradictoryEvidence(t *testing.T) { diff --git a/go/internal/loadpoint/controller.go b/go/internal/loadpoint/controller.go index 21bb34991..df8d6bb43 100644 --- a/go/internal/loadpoint/controller.go +++ b/go/internal/loadpoint/controller.go @@ -1554,6 +1554,12 @@ func (c *Controller) tickOne(ctx context.Context, now time.Time, lpCfg Config, s // 0 W standdown so the charger pauses cleanly. cmdW = 0 cmdReason = "no_plan_budget" + // The planner leaves out a car that declined current this + // session (Manager.observe latches it), so its slots carry + // nothing. The stop is Core's, for that car, not an empty plan. + if st, ok := c.manager.State(lpCfg.ID); ok && st.ChargingDeclined { + cmdReason = "vehicle_not_requesting" + } } finishW, finishing := c.vehicleCompletionOffer(lpCfg, now) if finishing { diff --git a/go/internal/loadpoint/controller_commanded_reason_test.go b/go/internal/loadpoint/controller_commanded_reason_test.go index 035597cd2..754490309 100644 --- a/go/internal/loadpoint/controller_commanded_reason_test.go +++ b/go/internal/loadpoint/controller_commanded_reason_test.go @@ -43,6 +43,54 @@ func TestCommandedReasonNoPlanBudget(t *testing.T) { } } +// srcfl/ftw#2080: a car with a goal and a deadline stopped asking for current +// while the plan offered it. Once that lasts SessionCompletionTimeout the +// planner leaves the car out for the session, so its slots carry no energy. +// Easee then reports request_active again, because Core's own 0 A is what it +// sees. The stop is Core's, for a car that declined; "no_plan_budget" says +// the plan simply chose not to charge, which is not why. +func TestCommandedReasonDeclinedCarIsNotAnEmptyPlan(t *testing.T) { + base := time.Date(2026, 11, 24, 22, 0, 0, 0, time.UTC) + clock := base + sender := &fakeSender{} + cfg := reasonLoadpoint() + dir := &Directive{ + SlotStart: base.Add(-time.Second), + SlotEnd: base.Add(15 * time.Minute), + LoadpointEnergyWh: map[string]float64{cfg.ID: 2750}, + } + samples := map[string]EVSample{cfg.DriverName: {Connected: true, PowerW: 11000, RequestActive: true}} + c := newTestController(t, []Config{cfg}, dir, samples, sender) + c.manager.SetNowFn(func() time.Time { return clock }) + c.manager.SetTarget(cfg.ID, 1, base.Add(9*time.Hour)) + + c.Tick(context.Background(), clock) + if w, r := commandedReason(t, c, cfg.ID); w <= 0 || r != "plan" { + t.Fatalf("charging to plan: got (%.0f, %q)", w, r) + } + + // The car stops asking while the plan still offers current. + samples[cfg.DriverName] = EVSample{Connected: true, PowerW: 0, RequestActive: false} + for clock.Sub(base) <= SessionCompletionTimeout+10*time.Second { + clock = clock.Add(5 * time.Second) + c.Tick(context.Background(), clock) + } + if st, _ := c.manager.State(cfg.ID); !st.ChargingDeclined { + t.Fatalf("lasting refusal under a live offer did not latch: %+v", st) + } + + // The next plan leaves the car out. Core holds 0 A and the charger + // reports the car as asking again. + dir.LoadpointEnergyWh = map[string]float64{} + samples[cfg.DriverName] = EVSample{Connected: true, PowerW: 0, RequestActive: true} + clock = clock.Add(5 * time.Second) + c.Tick(context.Background(), clock) + + if w, r := commandedReason(t, c, cfg.ID); w != 0 || r != "vehicle_not_requesting" { + t.Errorf("declined car left out of the plan: want (0, vehicle_not_requesting), got (%.0f, %q)", w, r) + } +} + func TestCommandedReasonPlan(t *testing.T) { base := time.Date(2026, 8, 30, 12, 0, 0, 0, time.UTC) sender := &fakeSender{} From 0f1d25c09882cdcd87a9a60c3f23e8afd674c0f9 Mon Sep 17 00:00:00 2001 From: Fredrik Ahlgren Date: Wed, 25 Nov 2026 08:38:07 +0100 Subject: [PATCH 2/2] fix(ev): say the declined-car reason also holds with no plan The comment now covers a missing plan or directive, not only a plan that leaves the car out. The changeset lists every exit from the latch. Refs srcfl/ftw#2080 Co-Authored-By: Claude Opus 5.5 Signed-off-by: Fredrik Ahlgren --- .changeset/declined-car-not-empty-plan.md | 5 +++-- go/internal/loadpoint/controller.go | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.changeset/declined-car-not-empty-plan.md b/.changeset/declined-car-not-empty-plan.md index dbc4399a0..ba6280056 100644 --- a/.changeset/declined-car-not-empty-plan.md +++ b/.changeset/declined-car-not-empty-plan.md @@ -5,6 +5,7 @@ A car that stopped asking for charge while FTW offered it now reads "Car not taking power" instead of "Waiting for the plan". The plan leaves such a car out for the rest of the session, so the old text blamed an empty plan for a -stop the car made. Nothing else changes: unplugging, a higher goal or Charge -now still lets FTW offer current again, and the battery level is never +stop the car made. Nothing else changes: unplugging, a higher goal, Charge +now, measured charging, or a car on a finish-at-limit goal reporting that it +is charging still lets FTW offer current again, and the battery level is never guessed from the stop. diff --git a/go/internal/loadpoint/controller.go b/go/internal/loadpoint/controller.go index df8d6bb43..462e9f80d 100644 --- a/go/internal/loadpoint/controller.go +++ b/go/internal/loadpoint/controller.go @@ -1554,9 +1554,10 @@ func (c *Controller) tickOne(ctx context.Context, now time.Time, lpCfg Config, s // 0 W standdown so the charger pauses cleanly. cmdW = 0 cmdReason = "no_plan_budget" - // The planner leaves out a car that declined current this - // session (Manager.observe latches it), so its slots carry - // nothing. The stop is Core's, for that car, not an empty plan. + // No budget for a car that declined current this session + // (Manager.observe latches it): the planner leaves it out, and + // with no plan or no directive the reason holds as well. The + // stop is Core's, for that car, not an empty plan. if st, ok := c.manager.State(lpCfg.ID); ok && st.ChargingDeclined { cmdReason = "vehicle_not_requesting" }