evcc icon indicating copy to clipboard operation
evcc copied to clipboard

Epic: Faster, parallel loadpoint control — decouple sensing from control

Open premultiply opened this issue 6 months ago • 6 comments

evcc's control loop handles one loadpoint per tick (default interval = 30 s). Each loadpoint's full pass — including the charger status read — only comes around every loadpoints × interval. On a site with several loadpoints that means:

  • "Vehicle plugged in" is noticed late. With 10 loadpoints at 30 s, a plug-in can take up to ~5 minutes to register.
  • Reactions don't scale. The more loadpoints, the slower everything gets.
  • Only one loadpoint can change its charging power per tick, so ramping many cars (e.g. at sunrise) takes minutes.

The interval was doing two unrelated jobs at once: how often we look and how often we change something. This epic separates them into two independent loops:

  1. Sensing — every loadpoint reads its status and measurements on its own fast loop (2 s for now) and publishes them immediately. Detection no longer depends on the number of loadpoints.
  2. Control — every interval all loadpoints are controlled against one site measurement, in priority order, instead of taking turns. A change (charger status, mode, limit) triggers control immediately.

Before / after

Situation (10 loadpoints, interval = 30 s) Before After
Vehicle plugged in up to ~5 min to notice ~2 s or instant on push-capable chargers
Sunrise: 10 cars start PV charging ramp up one-by-one, minutes all ramp within one interval
Live power/status in the UI updates when the loadpoint's turn comes updates every ~2 s
A single loadpoint (most homes) unchanged, controlled at interval unchanged, controlled at interval

The "in-flight reserve"

Controlling several loadpoints against one measurement is made safe by an in-flight reserve, which replaces the old "one change per tick" rule.

When a loadpoint raises its current, the extra power takes a few seconds to show up on the grid meter. If a second loadpoint is evaluated in that gap, it would see the same surplus as still free and grab it too — drawing twice the power and spiking grid import (or overloading a shared circuit).

This is avoided by reserving the expected extra draw for one interval after each change:

  • Without "the reserve": 5 kW surplus → loadpoint A grabs 5 kW; loadpoint B, evaluated 1 s later before the meter updates, also sees 5 kW free and grabs it → 10 kW drawn, grid import spike.
  • With the reserve: loadpoint A grabs 5 kW → that 5 kW is reserved → loadpoint B sees 0 kW free and waits → the meter catches up → the reserve disappears. No spike.

The reserve is self-correcting: it shrinks as the real power arrives and vanishes the moment the meter matches the setpoint — so it never holds back surplus longer than necessary, and a car that ramps up slowly is handled automatically. The same mechanism protects shared circuits: a loadpoint's reserved current counts against the breaker limit until it is actually measured, so two chargers on one circuit can't both ramp into an overload.

Optional extras

  • Push-capable chargers (Easee, Warp, OCPP) report status changes the instant they happen, so plug-in/-out is detected with near-zero latency instead of waiting for the next sense tick. Easee/Warp stream single measurements continuously, so for them only the status is pushed (a push per power sample would flood); OCPP also pushes its meter values, which arrive as one bulk sample at a bounded rate (MeterValueSampleInterval, default 10 s), keeping charger power/energy fresh without polling. Control itself uses the site grid meter, so this is purely about observability.

Config & compatibility

  • interval keeps its meaning (default 30 s): how often control regulates, and how long a just-made change stays "reserved".
  • Sensing runs at a fixed 2 s default, independent of interval.
  • Fully backward compatible — single-loadpoint setups behave exactly as before; multi-loadpoint sites simply react much faster.

Implementation details

  • A fast per-loadpoint Sense() loop publishes state and wakes control on a change. One slow charger never holds up the others.
  • Update() is split into observe() (reads, on the sense loop) and control() (actuation, on the control loop), serialized per loadpoint so a charger is never read and written at the same time.
  • Each loadpoint exposes an in-flight reserve of max(0, intended − measured); the site subtracts the reserved sum from available surplus, and every circuit adds it to its measured load before checking limits.
  • Push-capable chargers may call Notify() to request instant updates (PR #30374)

Status

  • [ ] Core — per-loadpoint sensing, control of all loadpoints per interval, in-flight reserve — #30367
  • [ ] Push-capable chargers — instant status on Easee / Warp / OCPP — #30374

premultiply avatar May 31 '26 11:05 premultiply

This should make https://github.com/evcc-io/evcc/pull/21513 at least partially obsolete, right? The main change there was to move status calls to pre-control, where currently, charge powers and currents are read. The remainign part of the PR is just a simple change.

mfuchs1984 avatar May 31 '26 17:05 mfuchs1984

Will this change affect the interval for updating all energy-flows (Energyflow-Ui with battery, grid and pv) or just the loadpoints?

florian240483 avatar Jun 01 '26 04:06 florian240483

At the end it will speed-up all metering updates.

premultiply avatar Jun 01 '26 07:06 premultiply

Is there a rough estimate of when this feature will be implemented?

domin211 avatar Jul 13 '26 16:07 domin211

@premultiply

domin211 avatar Jul 23 '26 15:07 domin211

Adding a real-world case for the "how often we change something" side of this epic.

I run evcc with a Tesla Wall Connector (twc3) and a Tesla, with current control going through the MyTeslaMate command proxy, in PV mode with the default 30s interval. On sunny days with patchy cloud evcc sends a set_charging_amps command on most control cycles. On two days this month that was about 100 commands, which hit my proxy's daily cap (1 credit per command) and caused 429 errors in evcc. Normal days are a handful of commands.

Because the wall connector can only be controlled through the car, every amp change is a cloud call that costs money and counts against a limit. The only lever today is the site-wide interval. I'm moving to 60s, but that slows everything else down too, including the reaction to sudden grid import.

The epic already separates how often we look from how often we act, and #30375 adds a per-charger sensing interval for rate-limited cloud chargers. Would a similar per-charger limit on how often current commands are sent (or a minimum change before sending one) fit in here? Control could still run at the normal interval but skip sending updates that are too frequent or too small.

This came up before in #20166, where a user asked for a command interval separate from the update interval. Happy to share logs or test a build.

yorkday avatar Oct 16 '26 06:10 yorkday