Skip to content

fix(control): let battery charging yield to the EV - #1672

Merged
frahlg merged 3 commits into
masterfrom
fix/ev-smooth-fuse-20261016
Oct 16, 2026
Merged

frahlg merged 3 commits into
masterfrom
fix/ev-smooth-fuse-20261016

Conversation

@frahlg

@frahlg frahlg commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Problem and result

A brief loss of fuse headroom could pause an EV for five minutes after the headroom returned. Repeated phase readings could also drive a safe charging step down to zero. Meanwhile, newer EV feedback combined with an older site reading could let the home battery claim power the car had already taken.

Keep the car's current charging request through the fuse clamp so optional home battery charging yields first. Resume after two safe control ticks, trim to a legal charging step, and recalculate the EV limit from measured headroom. A stopped or completed car releases its old plan reservation.

Scope and safety

  • Check the common raw power balance and the latest site/phase limits separately, so a measured increase cannot count twice. Keep room for later battery readings and orders that have not yet appeared at the site meter, including failed calls, lower follow-up orders and driver resets. Keep short observed stops in the bounded telemetry ring.
  • Preserve the nominal fuse, per-phase margin, tariff peak, charger minimum/current limits and stale-site standdown. The thermal fuse study does not grant overload headroom.
  • Keep the empty phase setting as the normal three-phase default. Use the actual command branch for the phase limit; release completed manual holds before allocating power. A concurrent change to fewer phases waits for the next allocation.
  • Preserve battery charge needed for measured export protection. Unconfirmed battery relief cannot fund an EV or another battery.
  • Checked open PR overlap. The changes in main.go and dispatch.go only wire the charging request snapshot and add the final battery cap; they leave the PV work in fix(control): mitigate PV-only export over limits #888 and other open feature branches intact.
  • The supplied log proves the startup pause and reduced charging power. It does not establish the cause of the three later zero-power observations.

Verification

Regression coverage includes startup, NaN and missing power, stale-to-fresh recovery, repeated phase readings, one- and three-phase charging, empty phase settings, manual-to-scheduled transitions, concurrent phase changes, Stop, completed goals, two chargers sharing one cap, late or ignored battery reductions, pending orders, source timestamps, fixed poll order, AC/DC power differences and recovery without an initial shared sample. Joined tests check the physical power sum at command time, including 600 generated load combinations and different device response orders.

  • The full control, loadpoint and telemetry package tests and race checks pass. Six independent regressions also pass on the final source.
  • ARM64 Linux test executables pass on a Raspberry Pi with simulated device senders, including the joined EV/battery sequence and the 600 generated budget cases. These tests do not operate the live equipment.
  • make verify passes on the final source: Go tests, vet/build, protocol boundaries, release checks and the native Energyplan integration.

Confirmation on the customer's charger and Pixii remains a beta field check.

Checklist

  • The change follows VISION.md and one selected scope.
  • I checked overlapping PRs and preserved their separate changes.
  • Relevant checks cover the changed behaviour and failure paths.
  • No UI changed.
  • A Changeset is included.
  • Every commit has a DCO sign-off.

Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
@frahlg
frahlg marked this pull request as ready for review October 16, 2026 17:29
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-10-16T17:31:58.436714Z a24f3be Draft marked ready
ℹ️ 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: a24f3bec64

ℹ️ 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".

Comment thread go/internal/control/ev_fuse_budget.go Outdated
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
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