From 9ecb5f0c742fc4e957ed51c0da2863e76df70804 Mon Sep 17 00:00:00 2001 From: Fredrik Ahlgren Date: Wed, 18 Nov 2026 18:09:53 +0200 Subject: [PATCH] fix(ev): wait up to 15 minutes while the charger's load balancing holds a start Easee support says its Equalizer lowers the charging current at once and raises it again up to 15 minutes after household use falls (srcfl/ftw#1948). During that wait the charger reads back FTW's order, signals 0 A and the car draws nothing. Core showed only Easee's reason code, called it "Not following" after two minutes, Charge now said the car was not drawing, and the resume retries logged a failed start. When the driver reports that the charger's own load balancing lets the car take less than the 6 A a car starts on (current_limited_by "load_balancer"), Core now: - reports waiting/load_balancer_wait for up to 15 minutes from the first zero reading under positive orders, then no_power_response as before; - keeps Charge now in "accepted" for that long, with load_balancer_a; - logs the failed start after the same wait. Safety pauses, a lower readback, a pilot a car could start on and a car that stopped asking keep their own verdicts. The words name the load balancing during and after the wait. Refs srcfl/ftw#1948 Co-Authored-By: Claude Opus 5.5 Signed-off-by: Fredrik Ahlgren --- .changeset/load-balancer-start-wait.md | 12 +++ go/cmd/ftw/ev_observation.go | 4 +- go/cmd/ftw/ev_observation_test.go | 20 ++++ go/internal/api/api_control_feedback.go | 23 +++- go/internal/api/api_control_scenarios_test.go | 1 + go/internal/api/api_ev_load_balancer_test.go | 100 +++++++++++++++++- go/internal/api/api_loadpoint_manual.go | 5 + go/internal/api/api_pilot_evidence_test.go | 2 + go/internal/loadpoint/controller.go | 3 + go/internal/loadpoint/controller_resume.go | 19 +++- .../controller_resume_load_balancer_test.go | 71 +++++++++++++ go/internal/loadpoint/load_balancer.go | 21 ++++ .../loadpoint/manual_load_balancer_test.go | 48 +++++++++ go/internal/loadpoint/manual_status.go | 15 ++- web/app.js | 11 ++ web/control-feedback.js | 15 ++- web/control-feedback.test.mjs | 30 ++++++ web/ev-manual-feedback.test.mjs | 19 ++++ 18 files changed, 409 insertions(+), 10 deletions(-) create mode 100644 .changeset/load-balancer-start-wait.md create mode 100644 go/internal/loadpoint/controller_resume_load_balancer_test.go create mode 100644 go/internal/loadpoint/load_balancer.go create mode 100644 go/internal/loadpoint/manual_load_balancer_test.go diff --git a/.changeset/load-balancer-start-wait.md b/.changeset/load-balancer-start-wait.md new file mode 100644 index 000000000..a5dd58e22 --- /dev/null +++ b/.changeset/load-balancer-start-wait.md @@ -0,0 +1,12 @@ +--- +"ftw": patch +--- + +A car whose start the charger's own load balancing holds back now reads +"Waiting for load balancing" instead of "Not following", and Charge now no +longer says the car is not drawing. The driver must report that the load +balancing leaves less than the 6 A a car starts on. Easee's Equalizer raises +the current slowly, up to 15 minutes after the home uses less, so FTW waits +that long. A start still missing after 15 minutes is reported as before, and +the next step names the load balancing. The resume retries log their failed +start after the same wait. diff --git a/go/cmd/ftw/ev_observation.go b/go/cmd/ftw/ev_observation.go index f88b75c02..dcf3c7e7b 100644 --- a/go/cmd/ftw/ev_observation.go +++ b/go/cmd/ftw/ev_observation.go @@ -29,6 +29,8 @@ func currentEVSample(r *telemetry.DerReading, health *telemetry.DriverHealth, wa PowerAt string `json:"power_observed_at"` PowerMaxAgeS int `json:"power_max_age_s"` EnergyAt string `json:"energy_observed_at"` + LimitA *float64 `json:"current_limit_a"` + LimitedBy string `json:"current_limited_by"` } if json.Unmarshal(r.Data, &d) != nil || (d.SessionWh != nil && *d.SessionWh < 0) { return loadpoint.EVSample{}, false @@ -45,7 +47,7 @@ func currentEVSample(r *telemetry.DerReading, health *telemetry.DriverHealth, wa } sample := loadpoint.EVSample{ConnectionGeneration: d.ConnectionGeneration, PowerW: r.RawW, PowerAt: r.UpdatedAt, PowerMaxAge: time.Duration(min(max(d.PowerMaxAgeS, 0), 180)) * time.Second, Connected: *d.Connected, RequestKnown: d.RequestActive != nil, RequestActive: active, DeviceID: deviceID, SessionID: d.SessionID, - SessionWhUnavailable: d.SessionWh == nil} + SessionWhUnavailable: d.SessionWh == nil, LoadBalancerHold: loadpoint.LoadBalancerHoldsStart(d.LimitA, d.LimitedBy)} _, powerKnown := telemetry.ControlPowerObservation(sample.PowerW, r.Data, r.UpdatedAt) sample.PowerUnavailable = !powerKnown if d.SessionWh != nil { diff --git a/go/cmd/ftw/ev_observation_test.go b/go/cmd/ftw/ev_observation_test.go index e5c79c7c9..21d58fa35 100644 --- a/go/cmd/ftw/ev_observation_test.go +++ b/go/cmd/ftw/ev_observation_test.go @@ -103,3 +103,23 @@ func TestEVObservationDistinguishesExplicitVehicleStopFromMissingRequest(t *test } } } + +// The loadpoint learns that the charger's own load balancing holds the start +// only from a named cause and a limit below what a car starts on. +func TestEVObservationReadsALoadBalancerHold(t *testing.T) { + now := time.Now() + health := &telemetry.DriverHealth{Status: telemetry.StatusOk} + for body, want := range map[string]bool{ + `{"connected":true,"current_limit_a":0,"current_limited_by":"load_balancer"}`: true, + `{"connected":true,"current_limit_a":5.5,"current_limited_by":"load_balancer"}`: true, + `{"connected":true,"current_limit_a":6,"current_limited_by":"load_balancer"}`: false, + `{"connected":true,"current_limit_a":0}`: false, + `{"connected":true,"current_limited_by":"load_balancer"}`: false, + `{"connected":true,"current_limit_a":-1,"current_limited_by":"load_balancer"}`: false, + } { + r := &telemetry.DerReading{UpdatedAt: now, Data: json.RawMessage(body)} + if s, ok := currentEVSample(r, health, time.Minute, now, false, "charger"); !ok || s.LoadBalancerHold != want { + t.Errorf("%s: hold %v, want %v", body, s.LoadBalancerHold, want) + } + } +} diff --git a/go/internal/api/api_control_feedback.go b/go/internal/api/api_control_feedback.go index 8da4d47c9..f3f7da0a8 100644 --- a/go/internal/api/api_control_feedback.go +++ b/go/internal/api/api_control_feedback.go @@ -208,7 +208,8 @@ func (s *Server) controlFeedback(now time.Time) []ControlFeedback { // last reading for a minute after the driver stops sending. The // driver checked its limit against the pilot when it was fresh, // so only the pilot becomes unknown. - if d.PilotConfirmedAtMs != nil && (!pilotValid || (pilotFresh && *d.PilotA == 0)) { + // A zero pilot agrees with load balancing that holds the start. + if d.PilotConfirmedAtMs != nil && (!pilotValid || (pilotFresh && *d.PilotA == 0 && !loadpoint.LoadBalancerHoldsStart(d.LimitA, d.LimitedBy))) { d.LimitA, d.LimitedBy = nil, "" } if d.LimitA != nil { @@ -442,6 +443,8 @@ func setControlStatus(f *ControlFeedback) { status = "limited" case "device_limit", "offered_current_lower": status, severity = "limited", "warning" + case "load_balancer_wait": + status = "waiting" case "setpoint_changed", "power_below_target", "power_above_target", "power_wrong_direction", "no_power_response", "power_while_idle": status, severity = "not_following", "warning" @@ -554,6 +557,24 @@ func classifyControlFeedback(f *ControlFeedback, cmd telemetry.CommandEvidence, set("waiting", "vehicle_declined", "info") return } + // The charger's own load balancing lets the car take too little to + // start. Easee raises that current slowly after household use falls, so + // Core waits LoadBalancerRaiseWait from the first zero reading under + // positive orders (a pause ends that run) before it reports no power. + // Safety pauses, a charger holding a lower order, a pilot the car could + // start on, and a run without that clock older than the wait keep their + // own verdicts. + if f.Kind == "ev" && commanded && cmd.Result == "accepted" && + coreReason != "site_meter_stale" && coreReason != "site_phase_currents_stale" && coreReason != "fuse_cooldown" && + f.SentW != nil && *f.SentW > 100 && f.ActualW != nil && math.Abs(*f.ActualW) < 100 && + loadpoint.LoadBalancerHoldsStart(f.LimitA, f.LimitedBy) && (f.RequestedA == nil || *f.LimitA+0.5 < *f.RequestedA) && + (f.OfferedA == nil || f.RequestedA == nil || *f.OfferedA+0.5 >= *f.RequestedA) && + (f.PilotA == nil || *f.PilotA < loadpoint.MinStartCurrentA) && + (!cmd.NoPowerSince.IsZero() && cmd.NoPowerAt.Sub(cmd.NoPowerSince) < loadpoint.LoadBalancerRaiseWait || + cmd.NoPowerSince.IsZero() && now.Sub(cmd.Since) < loadpoint.LoadBalancerRaiseWait) { + set("waiting", "load_balancer_wait", "info") + return + } // A positive clamp explains the lower offer, not prolonged zero delivery. // Keep known safety pauses and unconfirmed/stale commands authoritative. evMismatchObserved := !cmd.PowerMismatchSince.IsZero() && cmd.LastObservation.Sub(cmd.PowerMismatchSince) >= evMismatchWait diff --git a/go/internal/api/api_control_scenarios_test.go b/go/internal/api/api_control_scenarios_test.go index 4470550bf..4f27acab4 100644 --- a/go/internal/api/api_control_scenarios_test.go +++ b/go/internal/api/api_control_scenarios_test.go @@ -273,6 +273,7 @@ func TestControlStatusAnswersEveryReason(t *testing.T) { "battery_nearly_full": {"limited", "info"}, "fuse_limit": {"limited", "info"}, "load_balancer_limit": {"limited", "info"}, + "load_balancer_wait": {"waiting", "info"}, "device_limit": {"limited", "warning"}, "power_below_target": {"not_following", "warning"}, "setpoint_changed": {"not_following", "warning"}, diff --git a/go/internal/api/api_ev_load_balancer_test.go b/go/internal/api/api_ev_load_balancer_test.go index fd8901b97..fb0fdea98 100644 --- a/go/internal/api/api_ev_load_balancer_test.go +++ b/go/internal/api/api_ev_load_balancer_test.go @@ -11,6 +11,7 @@ import ( "github.com/srcfl/ftw/go/internal/config" "github.com/srcfl/ftw/go/internal/drivers" + "github.com/srcfl/ftw/go/internal/loadpoint" "github.com/srcfl/ftw/go/internal/telemetry" ) @@ -37,8 +38,12 @@ func TestEaseeLoadBalancingReadsAsLimited(t *testing.T) { {"nor a car 1.5 A under a 7 A limit", held + `,"current_limit_a":7,"current_limited_by":"load_balancer"`, 3800, "not_following", "power_below_target", "warning"}, {"nor a car at the order", named, 10300, "following", "power_observed", "info"}, {"limit at the order", held + `,"current_limit_a":15,"current_limited_by":"load_balancer"`, 8850, "not_following", "power_below_target", "warning"}, - {"a zero limit", held + `,"current_limit_a":0,"current_limited_by":"load_balancer"`, 0, "not_following", "no_power_response", "warning"}, - {"a zero limit, no readback", `,"current_limit_a":0,"current_limited_by":"load_balancer"`, 0, "not_following", "no_power_response", "warning"}, + // Load balancing that leaves less than a car starts on holds the + // start for a while (TestLoadBalancingHoldsAStartForFifteenMinutes). + {"a zero limit", held + `,"current_limit_a":0,"current_limited_by":"load_balancer"`, 0, "waiting", "load_balancer_wait", "info"}, + {"a zero limit, no readback", `,"current_limit_a":0,"current_limited_by":"load_balancer"`, 0, "waiting", "load_balancer_wait", "info"}, + {"a zero limit under a lower readback", `,"max_a":12,"current_limit_a":0,"current_limited_by":"load_balancer"`, 0, "not_following", "no_power_response", "warning"}, + {"a 6 A limit does not explain zero", held + `,"current_limit_a":6,"current_limited_by":"load_balancer"`, 0, "not_following", "no_power_response", "warning"}, // A charger that holds a lower order than FTW sent says so first. {"charger holds 12 A", `,"max_a":12,"current_limit_a":10,"current_limited_by":"load_balancer"`, 6900, "limited", "offered_current_lower", "warning"}, } { @@ -106,6 +111,97 @@ func TestEaseeLoadBalancingStepsUp(t *testing.T) { }) } +// Field report, 12 Nov 2026 (srcfl/ftw#1948), Easee Cloud with an Equalizer: +// FTW ordered 12 A, the charger read back 12 A, Easee allocated 0 A on all +// three phases and the car drew nothing. Easee raises the current again up +// to 15 minutes after household use falls. Core waits that long and then +// reports the start as failed; a start that comes in time follows. +func TestLoadBalancingHoldsAStartForFifteenMinutes(t *testing.T) { + const order, hold = 8280, `,"max_a":12,"current_limit_a":0,"current_limited_by":"load_balancer"` + run := func(t *testing.T, e *evTrace, w float64, d time.Duration, each func(ControlFeedback)) ControlFeedback { + var f ControlFeedback + for range int(d / (5 * time.Second)) { + e.tick(w, "plan") + f = e.verdict(t) + each(f) + } + return f + } + calm := func(t *testing.T, start time.Time) func(ControlFeedback) { + return func(f ControlFeedback) { + if f.Status == "not_following" || f.Severity != "info" { + t.Fatalf("at %v: %s/%s/%s", time.Since(start), f.Status, f.Reason, f.Severity) + } + } + } + t.Run("bounded", func(t *testing.T) { + synctest.Test(t, func(t *testing.T) { + e := newEVTrace(0) + e.extra = hold + start := time.Now() + var last time.Duration + f := run(t, e, order, 20*time.Minute, func(f ControlFeedback) { + since := time.Since(start) + switch { + case f.Reason == "load_balancer_wait": + last = since + if f.Status != "waiting" || f.Severity != "info" || f.LimitA == nil || *f.LimitA != 0 || + f.LimitedBy != "load_balancer" || f.RequestedA == nil || math.Abs(*f.RequestedA-12) > 0.01 { + t.Fatalf("at %v: %+v", since, f) + } + case since < loadpoint.LoadBalancerRaiseWait: + t.Fatalf("at %v, inside the wait: %s/%s", since, f.Status, f.Reason) + } + }) + if f.Status != "not_following" || f.Reason != "no_power_response" || f.Severity != "warning" { + t.Fatalf("after 20 min without a start: %s/%s/%s", f.Status, f.Reason, f.Severity) + } + // The limit and its cause stay on the failed row for the words. + if f.LimitA == nil || *f.LimitA != 0 || f.LimitedBy != "load_balancer" { + t.Fatalf("failed row lost the limit: %+v", f) + } + if wait := loadpoint.LoadBalancerRaiseWait; last < wait-10*time.Second || last >= wait+10*time.Second { + t.Fatalf("waited %v, want %v", last, wait) + } + }) + }) + t.Run("a start in time follows", func(t *testing.T) { + synctest.Test(t, func(t *testing.T) { + e := newEVTrace(0) + e.extra = hold + start := time.Now() + run(t, e, order, 11*time.Minute, calm(t, start)) + e.extra, e.drawW, e.changedAt = `,"max_a":12`, order, time.Now() + if f := run(t, e, order, 3*time.Minute, calm(t, start)); f.Status != "following" { + t.Fatalf("after the start: %s/%s", f.Status, f.Reason) + } + }) + }) + t.Run("a pause starts a new wait", func(t *testing.T) { + synctest.Test(t, func(t *testing.T) { + e := newEVTrace(0) + e.extra = hold + start := time.Now() + run(t, e, order, 12*time.Minute, calm(t, start)) + run(t, e, 0, time.Minute, calm(t, start)) + if f := run(t, e, order, 12*time.Minute, calm(t, start)); f.Reason != "load_balancer_wait" { + t.Fatalf("after the new start: %s/%s", f.Status, f.Reason) + } + }) + }) + t.Run("the hold ends without a start", func(t *testing.T) { + synctest.Test(t, func(t *testing.T) { + e := newEVTrace(0) + e.extra = hold + run(t, e, order, 5*time.Minute, func(ControlFeedback) {}) + e.extra = `,"max_a":12` + if f := run(t, e, order, 5*time.Second, func(ControlFeedback) {}); f.Reason != "no_power_response" { + t.Fatalf("allocation back, no draw: %s/%s", f.Status, f.Reason) + } + }) + }) +} + // The sentence names the charger's make with its limit, from the identity // its driver reported. Rows without a limit do not carry it. func TestChargerLimitCarriesTheMake(t *testing.T) { diff --git a/go/internal/api/api_loadpoint_manual.go b/go/internal/api/api_loadpoint_manual.go index a63134d59..2f1686307 100644 --- a/go/internal/api/api_loadpoint_manual.go +++ b/go/internal/api/api_loadpoint_manual.go @@ -331,6 +331,8 @@ func (s *Server) chargerReadings() map[string]loadpoint.ChargerReading { Reason string `json:"reason_no_current_label"` CommandStalled bool `json:"command_stalled"` Online *bool `json:"is_online"` + LimitA *float64 `json:"current_limit_a"` + LimitedBy string `json:"current_limited_by"` } if len(rd.Data) > 0 { _ = json.Unmarshal(rd.Data, &d) @@ -343,6 +345,9 @@ func (s *Server) chargerReadings() map[string]loadpoint.ChargerReading { r.LimitA = *d.MaxA r.LimitKnown = true } + if loadpoint.LoadBalancerHoldsStart(d.LimitA, d.LimitedBy) { + r.BalancerA = d.LimitA + } out[rd.Driver] = r } return out diff --git a/go/internal/api/api_pilot_evidence_test.go b/go/internal/api/api_pilot_evidence_test.go index 35d76c3fe..9fd950584 100644 --- a/go/internal/api/api_pilot_evidence_test.go +++ b/go/internal/api/api_pilot_evidence_test.go @@ -67,6 +67,8 @@ func TestPilotAwareDriverFeedback(t *testing.T) { {"future confirmation cannot explain power", 8850, 13, at13, false, -time.Minute, "not_following", "power_below_target", "warning"}, {"zero delivery stays visible", 0, 13, at13, false, 5 * time.Second, "not_following", "no_power_response", "warning"}, {"zero pilot cannot explain ongoing draw", 8850, 0, at13, false, 5 * time.Second, "not_following", "power_below_target", "warning"}, + {"zero pilot under load balancing that holds the start", 0, 0, `,"current_limit_a":0,"current_limited_by":"load_balancer"`, false, 5 * time.Second, "waiting", "load_balancer_wait", "info"}, + {"a pilot the car could start on is not a hold", 0, 6, `,"current_limit_a":0,"current_limited_by":"load_balancer"`, false, 5 * time.Second, "not_following", "no_power_response", "warning"}, {"delivery below effective pilot stays visible", 4000, 13, at13, false, 5 * time.Second, "not_following", "power_below_target", "warning"}, {"pilot above the order", 8850, 20, at13, false, 5 * time.Second, "limited", "offered_current_lower", "warning"}, {"pilot above the limit", 8850, 14.2, at13, false, 5 * time.Second, "limited", "offered_current_lower", "warning"}, diff --git a/go/internal/loadpoint/controller.go b/go/internal/loadpoint/controller.go index e0037fc20..21bb34991 100644 --- a/go/internal/loadpoint/controller.go +++ b/go/internal/loadpoint/controller.go @@ -340,6 +340,9 @@ type EVSample struct { RequestActive bool DeviceID string SessionID string + // LoadBalancerHold: the driver reports that the charger's own load + // balancing lets the car take less than it needs to start. + LoadBalancerHold bool } // PlanFunc returns the current-slot directive for now, or (_, false) diff --git a/go/internal/loadpoint/controller_resume.go b/go/internal/loadpoint/controller_resume.go index b238f276b..b0aa6144a 100644 --- a/go/internal/loadpoint/controller_resume.go +++ b/go/internal/loadpoint/controller_resume.go @@ -16,6 +16,9 @@ type resumeOffer struct { deliverySince, deliveryAt time.Time zeroOffer bool noDrawSince, noDrawAt time.Time + // holdSince is when the driver first reported, in this run without + // draw, that the charger's own load balancing holds the start. + holdSince time.Time } // Allow a missed five-second tick and ordinary cloud poll jitter. Repeating @@ -127,6 +130,11 @@ func (c *Controller) recoverOfferedCharge(ctx context.Context, cfg Config, sampl return // Already drawing: observe it rather than sending another resume. } previous.deliverySince, previous.deliveryAt = time.Time{}, time.Time{} + if !sample.LoadBalancerHold { + previous.holdSince = time.Time{} + } else if previous.holdSince.IsZero() { + previous.holdSince = now + } if !previous.zeroOffer { if previous.noDrawSince.IsZero() || observedAt.Before(previous.noDrawAt) || (!previous.noDrawAt.IsZero() && observedAt.Sub(previous.noDrawAt) > resumeObservationGap) { @@ -141,8 +149,12 @@ func (c *Controller) recoverOfferedCharge(ctx context.Context, cfg Config, sampl return } if previous.acknowledgedAttempts >= 3 { - if previous.acknowledgedAttempts == 3 { - slog.Warn("loadpoint resume acknowledged but no charge observed", "lp", cfg.ID, "driver", cfg.DriverName) + // The charger's own load balancing may hold a start for up to + // LoadBalancerRaiseWait. A start still missing after that, or one + // with no such hold, has failed. + if previous.acknowledgedAttempts == 3 && (previous.holdSince.IsZero() || now.Sub(previous.holdSince) >= LoadBalancerRaiseWait) { + slog.Warn("loadpoint resume acknowledged but no charge observed", "lp", cfg.ID, "driver", cfg.DriverName, + "load_balancer_hold", !previous.holdSince.IsZero()) previous.acknowledgedAttempts++ } return @@ -159,7 +171,8 @@ func (c *Controller) recoverOfferedCharge(ctx context.Context, cfg Config, sampl // three acknowledged attempts. Only observed delivery clears the proof. previous.acknowledgedAttempts++ slog.Info("loadpoint resume acknowledged; waiting for measured charge", "lp", cfg.ID, "driver", cfg.DriverName, - "attempt", previous.acknowledgedAttempts, "offer_w", offerW, "observed_w", sample.PowerW, "power_at", sample.PowerAt) + "attempt", previous.acknowledgedAttempts, "offer_w", offerW, "observed_w", sample.PowerW, "power_at", sample.PowerAt, + "load_balancer_hold", sample.LoadBalancerHold) previous.nextAttempt = now.Add(30 * time.Second) previous.retryDelay = 0 } diff --git a/go/internal/loadpoint/controller_resume_load_balancer_test.go b/go/internal/loadpoint/controller_resume_load_balancer_test.go new file mode 100644 index 000000000..e6866d481 --- /dev/null +++ b/go/internal/loadpoint/controller_resume_load_balancer_test.go @@ -0,0 +1,71 @@ +package loadpoint + +import ( + "bytes" + "context" + "log/slog" + "strings" + "testing" + "time" +) + +// Field report, srcfl/ftw#1948: an Easee Equalizer held the start for 11–14 +// minutes after FTW resumed the charger, and Core logged a failed start after +// its three resumes, about two minutes in. With the driver's word that the +// charger's own load balancing holds the start, Core waits up to +// LoadBalancerRaiseWait before it logs the failure; without it, or once the +// hold ends, a start that has not come has failed. +func TestResumeWarningWaitsOutALoadBalancerHold(t *testing.T) { + for _, tc := range []struct { + name string + hold bool + release time.Duration // when the driver stops reporting the hold; 0 never + warnAt time.Duration // when the failed start is logged, from the resume + }{ + {"no hold", false, 0, 90 * time.Second}, + {"held throughout", true, 0, LoadBalancerRaiseWait}, + {"hold ends without a start", true, 5 * time.Minute, 5 * time.Minute}, + } { + t.Run(tc.name, func(t *testing.T) { + var logs bytes.Buffer + previous := slog.Default() + slog.SetDefault(slog.New(slog.NewTextHandler(&logs, nil))) + t.Cleanup(func() { slog.SetDefault(previous) }) + + now := time.Date(2026, 11, 12, 2, 24, 0, 0, time.UTC) + sender := &fakeSender{} + cfg := Config{ID: "garage", DriverName: "easee", MinChargeW: 4140, MaxChargeW: 11000, AllowedStepsW: []float64{0, 4140, 8280, 11000}} + samples := map[string]EVSample{"easee": {Connected: true, RequestActive: true, DeviceID: "box", SessionID: "plug-1", + ConnectionGeneration: 1, LoadBalancerHold: tc.hold}} + dir := &Directive{SlotStart: now, SlotEnd: now.Add(time.Hour), LoadpointEnergyWh: map[string]float64{"garage": 0}} + c := newTestController(t, []Config{cfg}, dir, samples, sender) + c.Tick(context.Background(), now) + dir.LoadpointEnergyWh["garage"] = 8280 + resumed := now.Add(5 * time.Second) + warned := time.Duration(0) + for at := resumed; at.Before(resumed.Add(20 * time.Minute)); at = at.Add(5 * time.Second) { + if tc.release > 0 && at.Sub(resumed) >= tc.release { + sample := samples["easee"] + sample.LoadBalancerHold = false + samples["easee"] = sample + } + c.Tick(context.Background(), at) + if warned == 0 && strings.Contains(logs.String(), "no charge observed") { + warned = at.Sub(resumed) + } + } + if n := countAction(sender.calls, "ev_resume"); n != 3 { + t.Fatalf("resumes: %d, want 3 whether or not the start is held", n) + } + if warned < tc.warnAt || warned > tc.warnAt+10*time.Second { + t.Fatalf("failed start logged %v after the resume, want %v\n%s", warned, tc.warnAt, logs.String()) + } + if n := strings.Count(logs.String(), "no charge observed"); n != 1 { + t.Fatalf("failed start logged %d times", n) + } + if tc.hold && !strings.Contains(logs.String(), "load_balancer_hold=true") { + t.Fatalf("resume log does not name the hold:\n%s", logs.String()) + } + }) + } +} diff --git a/go/internal/loadpoint/load_balancer.go b/go/internal/loadpoint/load_balancer.go new file mode 100644 index 000000000..eea529d7f --- /dev/null +++ b/go/internal/loadpoint/load_balancer.go @@ -0,0 +1,21 @@ +package loadpoint + +import "time" + +// MinStartCurrentA is the least current a car charges on: 6 A per phase, the +// lowest pilot current in IEC 61851-1. A charger whose own load balancing +// lets the car take less holds the start back, whatever FTW orders. +const MinStartCurrentA = 6.0 + +// LoadBalancerRaiseWait bounds how long Core lets a charger's own load +// balancing hold back a start before it reports the start as failed. Easee +// support states that its Equalizer lowers the charging current at once but +// raises it again slowly, up to 15 minutes after household use falls, to +// protect relays and cars (srcfl/ftw#1948, 18 November 2026). +const LoadBalancerRaiseWait = 15 * time.Minute + +// LoadBalancerHoldsStart reports whether a driver's limit and its cause say +// that the charger's own load balancing lets the car take too little to start. +func LoadBalancerHoldsStart(limitA *float64, limitedBy string) bool { + return limitedBy == "load_balancer" && limitA != nil && finite(*limitA) && *limitA >= 0 && *limitA < MinStartCurrentA +} diff --git a/go/internal/loadpoint/manual_load_balancer_test.go b/go/internal/loadpoint/manual_load_balancer_test.go new file mode 100644 index 000000000..ae6c1e11e --- /dev/null +++ b/go/internal/loadpoint/manual_load_balancer_test.go @@ -0,0 +1,48 @@ +package loadpoint + +import ( + "testing" + "time" +) + +// Field report (srcfl/ftw#1948): after Charge now the Easee read back the +// order while its load balancing allowed 0 A for 10–14 minutes. The hold +// said the car was not drawing after two minutes, which blames the car. +// While the driver reports that the load balancing holds the start, the +// hold waits up to LoadBalancerRaiseWait; after that it is not drawing. +func TestManualHoldWaitsOutALoadBalancerHold(t *testing.T) { + t0 := time.Date(2026, 11, 12, 2, 24, 52, 0, time.UTC) + hold := ManualHold{PowerW: 8280, Persistent: true, StartedAt: t0} // 12 A × 3 × 230 V + st := State{Phases: 3, VoltageV: 230, CommandedW: 8280, CommandedKnown: true, CommandedReason: "manual_hold", CommandedSinceMs: t0.UnixMilli()} + zero, four, six := 0.0, 4.0, 6.0 + reading := func(balancer *float64) ChargerReading { + return ChargerReading{Known: true, LimitA: 12, LimitKnown: true, Reason: "limited by dynamic charger current", BalancerA: balancer} + } + for _, tc := range []struct { + name string + balancer *float64 + after time.Duration + want string + }{ + {"no hold reported", nil, 3 * time.Minute, ManualNotDrawing}, + {"held at 0 A", &zero, 3 * time.Minute, ManualAccepted}, + {"held at 4 A", &four, 14 * time.Minute, ManualAccepted}, + {"held past the wait", &zero, LoadBalancerRaiseWait, ManualNotDrawing}, + {"a limit at the order is no hold", &six, 3 * time.Minute, ManualNotDrawing}, + } { + t.Run(tc.name, func(t *testing.T) { + ch := reading(tc.balancer) + if tc.name == "a limit at the order is no hold" { + ch.LimitA, hold.PowerW, st.CommandedW = 6, 4140, 4140 + defer func() { hold.PowerW, st.CommandedW = 8280, 8280 }() + } + m := ManualStatusFrom(hold, true, st, ch, t0.Add(tc.after)) + if m.State != tc.want { + t.Fatalf("state %s, want %s", m.State, tc.want) + } + if (m.LoadBalancerA == nil) != (tc.balancer == nil) || m.LoadBalancerA != nil && *m.LoadBalancerA != *tc.balancer { + t.Fatalf("load balancer current %v, want %v", m.LoadBalancerA, tc.balancer) + } + }) + } +} diff --git a/go/internal/loadpoint/manual_status.go b/go/internal/loadpoint/manual_status.go index c008c5c8c..dce5840f7 100644 --- a/go/internal/loadpoint/manual_status.go +++ b/go/internal/loadpoint/manual_status.go @@ -42,6 +42,11 @@ type ManualStatus struct { // LimitReason names the clamp behind ManualLimited: "fuse_limit", // "import_limit", "fuse_cooldown" or "site_meter_stale". LimitReason string `json:"limit_reason,omitempty"` + // LoadBalancerA is the current the charger's own load balancing lets the + // car take, when its driver reports that this is too little to start. + // While it holds the start, the hold stays ManualAccepted for up to + // LoadBalancerRaiseWait before it is ManualNotDrawing. + LoadBalancerA *float64 `json:"load_balancer_a,omitempty"` } const ( @@ -88,6 +93,8 @@ type ChargerReading struct { Charging bool Reason string Stalled bool + // BalancerA: see ManualStatus.LoadBalancerA. Nil without that report. + BalancerA *float64 } const ( @@ -136,6 +143,7 @@ func ManualStatusFrom(h ManualHold, held bool, st State, ch ChargerReading, now ChargerLimitA: ch.LimitA, ChargerLimitKnown: ch.Known && ch.LimitKnown, ChargerReason: ch.Reason, + LoadBalancerA: ch.BalancerA, } if !ch.UpdatedAt.IsZero() { m.ChargerUpdatedAtMs = ch.UpdatedAt.UnixMilli() @@ -190,6 +198,9 @@ func ManualStatusFrom(h ManualHold, held bool, st State, ch ChargerReading, now m.LimitReason = st.CommandedReason } limitMatches := m.ChargerLimitKnown && m.CommandedA >= 0 && math.Abs(ch.LimitA-m.CommandedA) < 1 + // The charger holds the order, but its own load balancing does not let + // the car start yet. That is not a car that declines, for a while. + balancerWait := ch.BalancerA != nil && *ch.BalancerA+0.5 < m.CommandedA && elapsed < LoadBalancerRaiseWait switch { case ch.Unavailable || st.PowerUnavailable: m.State = ManualUnavailable @@ -205,11 +216,11 @@ func ManualStatusFrom(h ManualHold, held bool, st State, ch ChargerReading, now m.State = ManualSent case st.CurrentPowerW >= manualChargingFloorW: m.State = ManualCharging - case limitMatches && m.CommandedW >= manualChargingFloorW && elapsed >= manualAcceptGrace: + case limitMatches && m.CommandedW >= manualChargingFloorW && elapsed >= manualAcceptGrace && !balancerWait: m.State = ManualNotDrawing case clamp: m.State = ManualLimited - case limitMatches && elapsed >= manualAcceptGrace: + case limitMatches && elapsed >= manualAcceptGrace && !balancerWait: m.State = ManualNotDrawing case limitMatches: m.State = ManualAccepted diff --git a/web/app.js b/web/app.js index 5b8c9ac4c..1d4424b3b 100644 --- a/web/app.js +++ b/web/app.js @@ -2856,6 +2856,9 @@ var since = m.since_ms > 0 ? evFmtElapsed(Date.now() - m.since_ms) : ""; var sinceP = since ? " (" + since + ")" : ""; var reason = m.charger_reason ? " Charger reports: " + m.charger_reason + "." : ""; + // The driver reports that the charger's own load balancing lets the car + // take too little to start; Core waits up to 15 minutes for it. + var balancerA = typeof m.load_balancer_a === "number" && isFinite(m.load_balancer_a) ? Math.round(m.load_balancer_a) + " A" : ""; var end = lp.manual_release_soc > 0 ? " Returns to the plan at the estimated " + Math.round(lp.manual_release_soc * 100) + " % target." : " Continues until the car stops drawing, you return to the plan, or unplug."; @@ -2873,8 +2876,16 @@ case "sent": return "FTW received " + reqA + ". Waiting for the charger to confirm the new limit." + sinceP + ((lp.current_power_w || 0) >= 100 ? " Still charging at " + formatW(lp.current_power_w) + "." : "") + end; case "accepted": + if (balancerA) { + return "The charger holds " + cmdA + ", but its load balancing allows " + balancerA + ", too little for the car to start" + sinceP + + ". It raises the current slowly once the home uses less, which can take up to 15 minutes." + end; + } return "Charger reports a " + cmdA + " limit. Waiting for the car to start drawing…" + sinceP + reason + end; case "not_drawing": + if (balancerA) { + return "The charger’s load balancing still allows only " + balancerA + ", so the car has not started" + sinceP + + ". Compare its settings with FTW’s main fuse setting."; + } return "Charger offers " + cmdA + " but the car is not drawing" + sinceP + "." + (reason || " It may be full, or held by its own charge limit or schedule."); case "stalled": diff --git a/web/control-feedback.js b/web/control-feedback.js index ee245257f..bbd4c7d88 100644 --- a/web/control-feedback.js +++ b/web/control-feedback.js @@ -24,6 +24,13 @@ const percent = soc => num(soc) ? `${Math.round(soc * 100)}%` : 'its current lev const amps = value => num(value) ? `${Math.round(value)} A` : 'the current'; const clock = ms => num(ms) && ms > 0 ? new Date(ms).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'}) : ''; const capital = text => text.charAt(0).toUpperCase() + text.slice(1); +const balancer = row => row.make ? `${row.make}’s load balancing` : 'The charger’s load balancing'; +// Core's LoadBalancerRaiseWait and MinStartCurrentA (go/internal/loadpoint). +const BALANCER_WAIT = '15 minutes', START_A = 6; +// The driver says the charger's load balancing leaves less than a car starts +// on, and neither the pilot nor a lower setting on the charger says otherwise. +const balancerHolds = row => row.limited_by === 'load_balancer' && num(row.limit_a) && row.limit_a < START_A && + !(num(row.pilot_a) && row.pilot_a >= START_A) && !(num(row.offered_a) && num(row.requested_a) && row.offered_a + 0.5 < row.requested_a); // Site convention: positive power is drawn into the site, so a battery or car // charges and solar is negative. @@ -70,6 +77,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', + load_balancer_wait: 'Waiting for load balancing', 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', @@ -110,6 +118,7 @@ function sentence(row) { 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)}.`; + case 'load_balancer_wait': return `${balancer(row)} allows ${amps(row.limit_a)}, too little for the car to start. FTW asked for ${amps(row.requested_a)}.`; case 'one_phase': return `The car charges on ${row.charging_phase || 'one phase'} only${num(row.charging_phase_max_w) ? `, at most ${controlPower(row.charging_phase_max_w)}` : ''}. FTW plans with what it takes.`; case 'power_below_target': case 'power_above_target': return evPowerWarning(row) || `Asked for ${target(row)}, delivering ${controlPower(actual)}.`; case 'power_wrong_direction': return `Asked for ${target(row)}, but it is ${doing(row, actual)} ${controlPower(actual)}.`; @@ -148,7 +157,10 @@ function nextStep(row) { ? row.device_reason.trim() : ''; const chargerReport = reported ? `The charger reports: ${reported}.` : ''; switch (row.reason) { - case 'power_below_target': case 'no_power_response': + case 'no_power_response': + if (balancerHolds(row)) return `${balancer(row)} still allows only ${amps(row.limit_a)}. Compare its settings with FTW’s main fuse setting.`; + return chargerReport || `The ${name} has not said why. Check its app or display.`; + case 'power_below_target': return chargerReport || `The ${name} has not said why. Check its app or display.`; case 'power_above_target': case 'power_wrong_direction': case 'power_while_idle': return `The ${name} has not said why. Check its app or display.`; @@ -162,6 +174,7 @@ function nextStep(row) { case 'offered_current_lower': return [chargerReport, 'Check the charger’s load balancing and limits.'].filter(Boolean).join(' '); case 'charger_pilot_limit': return 'Check Available energy in the charger’s app for the active limit.'; case 'load_balancer_limit': return 'If this happens often, compare the charger’s load balancing settings with FTW’s main fuse setting.'; + case 'load_balancer_wait': return `It raises the current slowly once the home uses less, which can take up to ${BALANCER_WAIT}. FTW reports a problem if the car has not started by then.`; case 'observe_only': return 'Turn on control in the device settings if you want FTW to steer it.'; default: return ''; } diff --git a/web/control-feedback.test.mjs b/web/control-feedback.test.mjs index 127055712..43e9bb67e 100644 --- a/web/control-feedback.test.mjs +++ b/web/control-feedback.test.mjs @@ -237,6 +237,36 @@ test('the plan and what happens now, in words', () => { assert.equal(planNowWords({...morning, planned_battery_w: -3000, battery_w: -1000, why: 'less_home'}).then, 'The battery gives only what the home needs.'); }); +// Field report, 12 Nov 2026 (srcfl/ftw#1948): FTW asked for 12 A, Easee's +// load balancing allowed 0 A on all three phases, the car did not start. +test('a start held by load balancing waits calmly, then names the cause', () => { + const hold = {kind: 'ev', mode: 'plan', status: 'waiting', reason: 'load_balancer_wait', severity: 'info', make: 'Easee', + sent_w: 8280, actual_w: 0, requested_a: 12, offered_a: 12, pilot_a: 0, limit_a: 0, limited_by: 'load_balancer', + device_reason: 'limited by dynamic charger current'}; + const wait = controlStatus(row(hold)); + assert.equal(wait.title, 'Waiting for load balancing'); + assert.equal(wait.text, 'Easee’s load balancing allows 0 A, too little for the car to start. FTW asked for 12 A.'); + assert.equal(wait.next, 'It raises the current slowly once the home uses less, which can take up to 15 minutes. FTW reports a problem if the car has not started by then.'); + assert.equal(wait.tone, 'neutral'); + assert.equal(controlStatus(row({...hold, make: undefined})).text.split(',')[0], 'The charger’s load balancing allows 0 A'); + assert.deepEqual(controlNumbers(row(hold)).filter(([label]) => /current|allows/i.test(label)), [ + ['Requested current', '12 A'], ['Actual pilot current', '0 A'], ['Reported current setting', '12 A'], ['Load balancing allows', '0 A']]); + // The words name Core's own wait. + const go = readFileSync(new URL('../go/internal/loadpoint/load_balancer.go', import.meta.url), 'utf8'); + assert.match(go, /LoadBalancerRaiseWait = 15 \* time\.Minute/); + assert.match(go, /MinStartCurrentA = 6\.0/); + // Past the wait Core reports no power; the step names the load balancing. + const failed = {...hold, status: 'not_following', reason: 'no_power_response', severity: 'warning'}; + const stuck = controlStatus(row(failed)); + assert.equal(stuck.title, 'Not following'); + assert.equal(stuck.tone, 'warning'); + assert.equal(stuck.next, 'Easee’s load balancing still allows only 0 A. Compare its settings with FTW’s main fuse setting.'); + // Without that evidence the step stays as it was. + for (const other of [{limited_by: undefined}, {limit_a: 6}, {pilot_a: 6}, {offered_a: 10}, {limit_a: null}]) { + assert.equal(controlStatus(row({...failed, ...other})).next, 'The charger reports: limited by dynamic charger current.', JSON.stringify(other)); + } +}); + test('EV shortfalls show the reported reason without changing the verdict', () => { for (const reason of ['no_power_response', 'power_below_target', 'offered_current_lower', 'device_limit']) { const ev = row({kind: 'ev', reason, status: 'not_following', severity: 'warning', sent_w: 3680, diff --git a/web/ev-manual-feedback.test.mjs b/web/ev-manual-feedback.test.mjs index 96aba8e1f..6e641234d 100644 --- a/web/ev-manual-feedback.test.mjs +++ b/web/ev-manual-feedback.test.mjs @@ -32,6 +32,25 @@ test('the status line follows the charger through every state', () => { assert.match(statusText, /m\.since_ms/); }); +// srcfl/ftw#1948: the charger held 12 A while its load balancing allowed +// 0 A. The line names the load balancing instead of blaming the car. +test('a start held by load balancing names it, then reports the failure', () => { + const fn = new Function('formatW', 'evFmtElapsed', 'evIsPaused', statusText + '; return manualStatusText;')( + w => `${(w / 1000).toFixed(1)} kW`, () => '3 min', () => false); + const lp = {manual_active: true, manual: {active: true, state: 'accepted', requested_a: 12, commanded_a: 12, since_ms: 1, + load_balancer_a: 0, charger_reason: 'limited by dynamic charger current'}}; + assert.equal(fn(lp), 'The charger holds 12 A, but its load balancing allows 0 A, too little for the car to start (3 min). ' + + 'It raises the current slowly once the home uses less, which can take up to 15 minutes. ' + + 'Continues until the car stops drawing, you return to the plan, or unplug.'); + const failed = {...lp, manual: {...lp.manual, state: 'not_drawing'}}; + assert.equal(fn(failed), 'The charger’s load balancing still allows only 0 A, so the car has not started (3 min). ' + + 'Compare its settings with FTW’s main fuse setting.'); + // Without that report the words stay as they were. + const plain = {...failed, manual: {...failed.manual, load_balancer_a: undefined}}; + assert.match(fn(plain), /^Charger offers 12 A but the car is not drawing \(3 min\)\. Charger reports:/); + assert.match(fn({...lp, manual: {...lp.manual, load_balancer_a: null}}), /^Charger reports a 12 A limit\./); +}); + test('the manual controls follow every poll', () => { assert.match(manual, /return \{ el: box, update: update \};/); assert.match(source, /manual\.update\(nextLp, d\);/);