Skip to content

fix(ev): keep a steady charge running when the power reading does not change - #1417

Merged
frahlg merged 1 commit into
masterfrom
fix/ev-steady-power-no-stop
Sep 25, 2026
Merged

frahlg merged 1 commit into
masterfrom
fix/ev-steady-power-no-stop

Conversation

@frahlg

@frahlg frahlg commented Sep 25, 2026

Copy link
Copy Markdown
Member

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.lua reports power_observed_at as 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.
  • Since 67439f4/9a851664 (2026-09-13), Core marks a non-zero reading older than power_max_age_s (180 s for Easee) as PowerUnavailable. It then stands the charger down with ev_set_current 0 and reason charger_power_stale, which is not logged.
  • The fresh 0 W reading makes the power "available" again, the plan restarts the charge, and after 180 s it repeats.

Evidence from the night:

  • 10-second series of ev_w and ev_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.
  • Grid phases were at 7–15 A and the home battery at 0 W, so this was not a fuse overload.
  • The plan wanted continuous charging, about 6.9 kW per slot, and the slot budgets were only 26–39 % spent at each cut.
  • Easee command timeouts happened only twice (17:03, 19:49).

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

  1. A stale charger power reading alone no longer stands a charger down. In loadpoint/controller.go, only !dispatchAllowed (a stale site meter) triggers standDownBeforeStorage, and tickOne only returns early for that.
    • An old reading from a live driver is not a hardware risk: the fuse clamps work from the site meter.
    • observeEnergy and session accounting already treat stale power as unmeasured time.
    • A dead driver still produces no sample, and the driver-health owner applies its default mode.
    • Battery boost stays gated on fresh power.
  2. No replan for a stop Core ordered. 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

  • New 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 to TestUnavailablePowerKeepsManualCharge. 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.
  • New TestEVStopReplanOnlyWhenTheCarStoppedItself.
  • Runs: go test ./cmd/ftw ./internal/loadpoint ./internal/mpc and go vet pass.

Also seen

  • The home box had fuse.max_amps: 16 for 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

… 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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T04:38:00.029739Z 6739f32 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@frahlg
frahlg merged commit a4a1bde into master Sep 25, 2026
16 checks passed
frahlg added a commit to srcfl/device-drivers that referenced this pull request Sep 25, 2026
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]>
frahlg added a commit that referenced this pull request Sep 25, 2026
…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]>
@frahlg
frahlg deleted the fix/ev-steady-power-no-stop branch November 11, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant