From 31ee67485748056556c9df06095184e729bd475a Mon Sep 17 00:00:00 2001 From: Segran Date: Sun, 22 Nov 2026 00:33:42 +0100 Subject: [PATCH] fix(ev): show uncertainty when charger pilot data expires Signed-off-by: Segran --- .changeset/stale-pilot-underdraw.md | 5 +++++ go/internal/api/api_control_feedback.go | 9 ++++++++- go/internal/api/api_pilot_evidence_test.go | 7 +++++++ web/control-feedback.js | 2 ++ web/control-feedback.test.mjs | 7 +++++++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .changeset/stale-pilot-underdraw.md diff --git a/.changeset/stale-pilot-underdraw.md b/.changeset/stale-pilot-underdraw.md new file mode 100644 index 000000000..1f37d94ac --- /dev/null +++ b/.changeset/stale-pilot-underdraw.md @@ -0,0 +1,5 @@ +--- +"ftw": patch +--- + +Show that FTW is waiting for fresh charger pilot data when a car is charging below its order and the charger reports no limit. diff --git a/go/internal/api/api_control_feedback.go b/go/internal/api/api_control_feedback.go index a99924e23..04b337abb 100644 --- a/go/internal/api/api_control_feedback.go +++ b/go/internal/api/api_control_feedback.go @@ -36,7 +36,8 @@ type ControlFeedback struct { SiteEvidence *ControlComparison `json:"site_evidence,omitempty"` ToleranceW *float64 `json:"tolerance_w"` // Internal steps of the verdict; the API exposes their result above. - State string `json:"-"` + State string `json:"-"` + pilotStale bool VerificationTier *int `json:"-"` VerificationLost bool `json:"-"` Escalated bool `json:"-"` // not following long enough to be an alarm @@ -198,6 +199,7 @@ func (s *Server) controlFeedback(now time.Time) []ControlFeedback { f.DynamicLimitA = d.DynamicLimitA pilotAge, pilotValid := pilotReadingAge(d, now) pilotFresh := pilotValid && pilotAge <= pilotFreshFor + f.pilotStale = pilotValid && !pilotFresh if pilotFresh { f.PilotA, f.PilotObservedAt, f.PilotConfirmedAtMs = d.PilotA, d.PilotObservedAt, *d.PilotConfirmedAtMs } @@ -689,6 +691,11 @@ func classifyControlFeedback(f *ControlFeedback, cmd telemetry.CommandEvidence, reason = "power_wrong_direction" case math.Abs(*f.ActualW) < math.Abs(*f.SentW): reason = "power_below_target" + if f.Kind == "ev" && cmd.Result == "accepted" && *f.SentW > 100 && + *f.ActualW >= 100 && f.LimitA == nil && f.pilotStale { + set("waiting", "charger_pilot_stale", "info") + return + } } set("warning", reason, "warning") // FTW cannot stop a charger that draws more than it is told. A car diff --git a/go/internal/api/api_pilot_evidence_test.go b/go/internal/api/api_pilot_evidence_test.go index 018a73f14..80187d89b 100644 --- a/go/internal/api/api_pilot_evidence_test.go +++ b/go/internal/api/api_pilot_evidence_test.go @@ -204,6 +204,13 @@ func TestFreshPilotExplainsTheDrawWhileTheDriverWithholdsItsLimit(t *testing.T) read(time.Now(), "") e.tick(8970, "plan") check("second confirmation without the limit", "limited", "charger_pilot_limit", "info") + for range int(pilotFreshFor/(5*time.Second)) + 1 { + e.tick(8970, "plan") + } + check("pilot confirmation expired", "waiting", "charger_pilot_stale", "info") + read(time.Now(), "") + e.tick(8970, "plan") + check("pilot confirmed again", "limited", "charger_pilot_limit", "info") }) }) } diff --git a/web/control-feedback.js b/web/control-feedback.js index ee245257f..e94957dba 100644 --- a/web/control-feedback.js +++ b/web/control-feedback.js @@ -70,6 +70,7 @@ const REASON_TITLES = { import_limit: 'Limited by the hourly import limit', charger_limit: 'Limited by FTW’s charger setting', device_limit: 'Charger limit', offered_current_lower: 'Charger offers less current', load_balancer_limit: 'Limited by the charger’s load balancing', charger_pilot_limit: 'Limited by the charger', + charger_pilot_stale: 'Waiting for current pilot data', one_phase: 'Charging on one phase', device_fault: 'Device fault', telemetry_stale: 'No fresh readings', readings_lost: 'Lost control', command_failed: 'Commands failing', command_unconfirmed: 'Command not confirmed', default_failed: 'Cannot hand back control', @@ -107,6 +108,7 @@ function sentence(row) { case 'offered_current_lower': return num(row.limit_a) && !(num(row.offered_a) && num(row.requested_a) && row.offered_a + 0.5 < row.requested_a) ? `The charger lets the car take ${amps(row.limit_a)}, below the ${amps(row.requested_a)} FTW asked for.` : `The charger offers ${amps(row.offered_a)}, below the ${amps(row.requested_a)} FTW asked for.`; + case 'charger_pilot_stale': return `Charging at ${controlPower(actual)} against ${target(row)}. Waiting for a fresh pilot reading to explain the difference.`; case 'charger_pilot_limit': return `The charger signals ${amps(row.pilot_a)} to the car. FTW asked for ${amps(row.requested_a)}; measured charging is ${controlPower(actual)}. The internal limiting cause is unknown.`; case 'load_balancer_limit': return `${row.make ? `${row.make} limits the charger to ${amps(row.limit_a)} (its load balancing)` : `The charger’s load balancing limits it to ${amps(row.limit_a)}`}. FTW asked for ${amps(row.requested_a)}; the car takes ${controlPower(actual)}.`; diff --git a/web/control-feedback.test.mjs b/web/control-feedback.test.mjs index 127055712..ce952f93f 100644 --- a/web/control-feedback.test.mjs +++ b/web/control-feedback.test.mjs @@ -278,3 +278,10 @@ test('EV warnings show fresh pilot evidence with the measured charging power', ( assert.doesNotMatch(controlStatus({...stopped, readings_fresh: false}).text, /signalled/); assert.doesNotMatch(controlStatus({...stopped, pilot_a: null}).text, /signalled/); }); + +test('stale pilot calls for current evidence without attributing the limit', () => { + const status = controlStatus(row({kind:'ev',status:'waiting',reason:'charger_pilot_stale', + severity:'info',sent_w:8970,actual_w:5440})); + assert.equal(status.title, 'Waiting for current pilot data'); + assert.match(status.text, /Waiting for a fresh pilot reading/); +});