From db994b7f01f336ad93a1c73c060a07f5fe721204 Mon Sep 17 00:00:00 2001 From: Fredrik Ahlgren Date: Sat, 21 Nov 2026 19:04:04 +0100 Subject: [PATCH] fix(ev): let a fresh pilot explain the draw while the driver withholds its limit srcfl/ftw#2056: a steady Easee charge under load balancing (13 A order and readback, 8 A pilot, 5.44 kW) read Not following for 15 s between two pilot confirmations a minute apart, though the pilot was still fresh. The load-balancing verdict needed the driver's current_limit_a; without it nothing explained the draw, and the mismatch clock, running since the limit began, made the verdict Not following at once. The test driver, built on srcfl/device-drivers#200, withholds its limit for up to 30 s after its order reading moves. While the driver reports no limit, a fresh pilot below the order now explains a draw that matches it, as limited/charger_pilot_limit/info. Only the driver can name the load balancing. A car taking far less than the pilot is still Not following. Refs #2056 Co-Authored-By: Claude Opus 5.5 Signed-off-by: Fredrik Ahlgren --- .changeset/fresh-pilot-explains-draw.md | 17 +++++ go/internal/api/api_control_feedback.go | 20 ++++-- go/internal/api/api_pilot_evidence_test.go | 82 ++++++++++++++++++++++ 3 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 .changeset/fresh-pilot-explains-draw.md diff --git a/.changeset/fresh-pilot-explains-draw.md b/.changeset/fresh-pilot-explains-draw.md new file mode 100644 index 000000000..f63fc6917 --- /dev/null +++ b/.changeset/fresh-pilot-explains-draw.md @@ -0,0 +1,17 @@ +--- +"ftw": patch +--- + +Keep a charge under the charger's load balancing at Limited when the driver +briefly stops reporting its limit (srcfl/ftw#2056). + +An Easee charger read back FTW's 13 A order while its load balancing +signalled 8 A to the car, which took 5.44 kW. The EV status said "Limited by +the charger's load balancing", then "Not following" for 15 s, then Limited +again, though the 8 A pilot reading was still fresh. The test driver, built +on the open pilot change in srcfl/device-drivers#200, stops reporting its +limit for up to 30 s after its order reading moves. Core now lets a fresh +pilot below the order explain a draw that matches it. The status stays +Limited and reads "Limited by the charger" with the pilot current, because +only the driver can name the load balancing. A car that takes far less than +the pilot is still Not following. diff --git a/go/internal/api/api_control_feedback.go b/go/internal/api/api_control_feedback.go index 51606da85..a99924e23 100644 --- a/go/internal/api/api_control_feedback.go +++ b/go/internal/api/api_control_feedback.go @@ -607,16 +607,26 @@ func classifyControlFeedback(f *ControlFeedback, cmd telemetry.CommandEvidence, // more keeps its verdict. A fresh pilot names the charger as the cause // only when it is below the order and is that current. A lower current // whose cause the driver does not show still asks for a look. - if f.Kind == "ev" && commanded && cmd.Result == "accepted" && f.SentW != nil && f.RequestedW != nil && f.RequestedA != nil && f.LimitA != nil && f.ActualW != nil && - *f.SentW > 100 && *f.RequestedA > 0 && *f.LimitA > 0 && *f.LimitA+0.5 < *f.RequestedA && settled { + // + // While the driver reports no limit, a fresh pilot is that current: the + // charger signals it to the car now. easee_cloud stops reporting its + // limit for up to 30 s after its order reading moves, though its pilot + // stays fresh (srcfl/ftw#2056). Only the driver can name the load + // balancing, so the pilot alone names the charger. + limitA := f.LimitA + if limitA == nil { + limitA = f.PilotA + } + if f.Kind == "ev" && commanded && cmd.Result == "accepted" && f.SentW != nil && f.RequestedW != nil && f.RequestedA != nil && limitA != nil && f.ActualW != nil && + *f.SentW > 100 && *f.RequestedA > 0 && *limitA > 0 && *limitA+0.5 < *f.RequestedA && settled { perA := *f.RequestedW / *f.RequestedA - limitW := *f.LimitA * perA + limitW := *limitA * perA tolerance := telemetry.ControlToleranceW(limitW) if *f.ActualW >= limitW-math.Max(tolerance, math.Min(2*perA, 0.15*limitW)) && *f.ActualW <= limitW+tolerance && *f.ActualW < *f.SentW { if f.LimitedBy == "load_balancer" { set("limited", "load_balancer_limit", "info") - } else if f.PilotA != nil && *f.PilotA+0.5 < *f.RequestedA && math.Abs(*f.PilotA-*f.LimitA) <= 0.5 { - if f.DeviceLimitA != nil && math.Abs(*f.LimitA-*f.DeviceLimitA) <= 0.5 { + } else if f.PilotA != nil && *f.PilotA+0.5 < *f.RequestedA && math.Abs(*f.PilotA-*limitA) <= 0.5 { + if f.DeviceLimitA != nil && math.Abs(*limitA-*f.DeviceLimitA) <= 0.5 { set("limited", "device_limit", "info") } else { set("limited", "charger_pilot_limit", "info") diff --git a/go/internal/api/api_pilot_evidence_test.go b/go/internal/api/api_pilot_evidence_test.go index 35d76c3fe..018a73f14 100644 --- a/go/internal/api/api_pilot_evidence_test.go +++ b/go/internal/api/api_pilot_evidence_test.go @@ -126,3 +126,85 @@ func TestPilotLimitNeverHidesCommandFailureOrPendingCommand(t *testing.T) { }) } } + +// Field report srcfl/ftw#2056, 21 Nov 2026, v0.165.1-beta.1, Easee Cloud +// with a test driver built on easee_cloud's pilot evidence: FTW ordered +// 13 A on three phases (8.97 kW), the charger read back 13 A, Easee's load +// balancing signalled 8 A and the car took 5.44 kW. Pilot confirmations +// came a minute apart. Between them the verdict turned to Not following +// for 15 s although the 8 A pilot was still fresh. That driver stops +// reporting its limit for up to 30 s after its order reading moves, until +// the pilot answers the order again. A fresh pilot still names the charger +// as the cause, but not its load balancing, which only the driver can. +func TestFreshPilotExplainsTheDrawWhileTheDriverWithholdsItsLimit(t *testing.T) { + const balanced = `,"current_limit_a":8,"current_limited_by":"load_balancer"` + for _, tc := range []struct { + name string + gapW float64 + status, reason, severity string + }{ + {"steady draw at the pilot", 5440, "limited", "charger_pilot_limit", "info"}, + {"car far below the pilot", 3000, "not_following", "power_below_target", "warning"}, + } { + t.Run(tc.name, func(t *testing.T) { + synctest.Test(t, func(t *testing.T) { + source := time.Now().Add(-time.Hour).Format(time.RFC3339Nano) + e := newEVTrace(5440) + read := func(confirmed time.Time, limit string) { + e.extra = fmt.Sprintf(`,"max_a":13,"dynamic_limit_a":13,"pilot_a":8,"pilot_observed_at":%q,"pilot_confirmed_at_ms":%d%s`, source, confirmed.UnixMilli(), limit) + } + check := func(when, status, reason, severity string) { + t.Helper() + f := e.verdict(t) + if f.Status != status || f.Reason != reason || f.Severity != severity { + t.Fatalf("%s: got %s/%s/%s want %s/%s/%s", when, f.Status, f.Reason, f.Severity, status, reason, severity) + } + } + // Five minutes under the balancer's 8 A, confirmed every minute. + for i := range 5 * 60 / 5 { + if i%12 == 0 { + read(time.Now(), balanced) + } + e.tick(8970, "plan") + } + first := time.Now() + read(first, balanced) + e.tick(8970, "plan") + check("first confirmation", "limited", "load_balancer_limit", "info") + for range 5 { + e.tick(8970, "plan") + } + // 30 s after the confirmation the driver reports no limit for + // 15 s. The pilot it confirmed stays fresh. + read(first, "") + if tc.gapW != e.drawW { + e.drawW, e.changedAt = tc.gapW, time.Now() + } + for range 3 { + e.tick(8970, "plan") + check(fmt.Sprintf("gap at %v", time.Since(first)), tc.status, tc.reason, tc.severity) + } + if f := e.verdict(t); f.PilotA == nil || *f.PilotA != 8 || f.LimitA != nil || f.LimitedBy != "" { + t.Fatalf("gap evidence: pilot %v, limit %v by %q", f.PilotA, f.LimitA, f.LimitedBy) + } + if tc.status != "limited" { + return + } + read(first, balanced) + e.tick(8970, "plan") + check("limit back", "limited", "load_balancer_limit", "info") + for range 2 { + e.tick(8970, "plan") + } + read(time.Now(), balanced) + e.tick(8970, "plan") + check(fmt.Sprintf("second confirmation at %v", time.Since(first)), "limited", "load_balancer_limit", "info") + // A second confirmation while the driver still withholds the + // limit keeps the charger as the cause. + read(time.Now(), "") + e.tick(8970, "plan") + check("second confirmation without the limit", "limited", "charger_pilot_limit", "info") + }) + }) + } +}