Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stale-pilot-underdraw.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 8 additions & 1 deletion go/internal/api/api_control_feedback.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions go/internal/api/api_pilot_evidence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
})
}
Expand Down
2 changes: 2 additions & 0 deletions web/control-feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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)}.`;
Expand Down
7 changes: 7 additions & 0 deletions web/control-feedback.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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/);
});
Loading