Repository navigation
fix(ev): keep a steady charge running when the power reading does not change - #1417
Conversation
… change On the home box a Tesla on an Easee charger stopped 31 times in one night. Easee reports TotalPower only when it changes, so the driver's power_observed_at stays at the last change while the car charges at a steady current. After the declared 180 s window Core marked the reading stale and stood the charger down to 0 A with reason charger_power_stale; the fresh 0 W reading then let the plan start it again. 23 of 31 stops came 170-190 s after the last power change (median 178 s). An old charger power reading from a live driver is not a hardware risk: the fuse clamps work from the site meter, and energy accounting already treats the gap as unmeasured. Only a stale site meter now stands chargers down. The new test reproduces the stop at 190 s on the old controller. Each stop also fired "loadpoint EV stopped → MPC replan", 65 plans in two hours. A stop Core ordered itself now triggers no replan. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6739f32612
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return | ||
| } | ||
| if !dispatchAllowed || sample.PowerUnavailable { | ||
| if !dispatchAllowed { |
There was a problem hiding this comment.
Preserve EV draw when continuing stale power samples
When a surplus-only charger has an old power timestamp, this now continues dispatch after ObserveSample has converted PowerUnavailable into CurrentPowerW == 0. main.go consequently reports zero from SurplusChargingW, so the self-consumption controller no longer subtracts the EV's real draw from coverable grid import and may discharge the home battery into the EV during PV shortfalls—the exact behavior the surplus-only accounting is designed to prevent. Keep the last known draw for this accounting path, or otherwise prevent stale power from being treated as an observed zero while charging continues.
AGENTS.md reference: AGENTS.md:L22-L23
Useful? React with 👍 / 👎.
Easee records TotalPower (observation 120) only when it changes. The driver passed that timestamp as power_observed_at, so a car charging at a steady current reported power that looked older and older although every 5 s poll confirmed it. FTW treats a non-zero reading older than power_max_age_s (180 s) as stale; on the owner's box it stood the charger down about every three minutes all night (srcfl/ftw#1417). An unchanged value now omits power_observed_at, so the host stamps the reading when it arrives. A new value keeps Easee's source time, and an offline charger still emits no sample. No clock arithmetic: the 32-bit Lua harness cannot hold epoch milliseconds exactly. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7 Signed-off-by: Fredrik Ahlgren <[email protected]>
…1419) Moves the bundled-driver pin from d44fda1 to srcfl/device-drivers 489c937 (#131). easee_cloud 1.3.3 omits power_observed_at while the power is unchanged since the last poll, so Core stamps the reading on arrival instead of treating a steady charge as a stale charger (#1417). The same range brings nibe_local 1.2.0, whose Solar PV surplus feed is off by default and triple-gated; this also closes the pin lag in #1274. Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7 Co-authored-by: Claude Opus 5.5 <[email protected]>
Why
On the home box (v0.134.2 → v0.136.3-beta.1) a Tesla on an Easee charger charged overnight in a start-stop loop. Core stopped the charger 31 times between 23:50 and 05:10, about every 3–4 minutes; the car only notified some of the stops.
Root cause:
easee_cloud.luareportspower_observed_atas Easee's timestamp for observation 120 (TotalPower), and Easee records that only when the value changes. At a steady current the timestamp stays at the last change even though the driver polls every 5 s.power_max_age_s(180 s for Easee) asPowerUnavailable. It then stands the charger down withev_set_current 0and reasoncharger_power_stale, which is not logged.Evidence from the night:
ev_wandev_dynamic_current_a: 23 of 31 Core-commanded 0 A drops came 170–190 s after the last power change (median 178 s). For example, power last changed at 00:21:20, 00:25:00, 00:29:20, 00:32:40 and 00:36:20; Core cut to 0 A at 00:24:10, 00:28:00, 00:32:10, 00:35:50 and 00:39:30.Amplifier: every stop fired
loadpoint EV stopped → MPC replan triggered(37 times; 65 plans between 00:20 and 02:05), including stops Core ordered itself.What
loadpoint/controller.go, only!dispatchAllowed(a stale site meter) triggersstandDownBeforeStorage, andtickOneonly returns early for that.observeEnergyand session accounting already treat stale power as unmeasured time.evStopNeedsReplan(cmd/ftw/ev_stop_replan.go) fires only when the car stopped while Core still offered ≥50 W, or when no command is known yet.The Easee driver's timestamp meaning is fixed separately in
srcfl/device-drivers, with a pin bump to follow.Tests
TestSteadyChargingWithUnchangedPowerReadingKeepsCharging: it simulates Easee (whole amps, power reported only on change) over 12 minutes at a planned 6900 W. On the old controller it fails with "steady charge stopped at 190s … reason charger_power_stale"; with the fix it keeps charging.TestUnavailablePowerPausesAndRetainsManualCharge: renamed toTestUnavailablePowerKeepsManualCharge. It encoded the old rule, so it now asserts the manual charge continues and the hold remains.TestSafetyStopsAllChargersBeforeBlockedSessionSave: keeps the site-meter case; the charger-power case no longer stands down.TestEVStopReplanOnlyWhenTheCarStoppedItself.go test ./cmd/ftw ./internal/loadpoint ./internal/mpcandgo vetpass.Also seen
fuse.max_amps: 16for a 20 A fuse, so the per-phase clamp worked constantly: 1,192 clamps and 89 fuse-saturated replans. The owner has corrected the setting.🤖 Generated with Claude Code
https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7