Skip to content

fix(control): car charging takes priority over home battery charging (#1868) - #1872

Merged
frahlg merged 1 commit into
masterfrom
codex/ev-first-under-fuse
Oct 27, 2026
Merged

frahlg merged 1 commit into
masterfrom
codex/ev-first-under-fuse

Conversation

@frahlg

@frahlg frahlg commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Closes #1868.

A 0.1 A phase overage reduced the car's 4140 W offer to 4071 W. The car's only nonzero step was 4140 W, so it stopped while the home battery kept charging. After stopping, the battery reserved exactly the requested car power, but the idle-start guard required another unused step. That could prevent an automatic restart.

The car has priority over optional home battery charging in every battery mode, including manual battery holds and self-tune. An existing car offer may wait up to 20 seconds for battery charging to fall, only while fresh phase readings, fuse heat and outstanding raises stay within the rated main fuse current. Battery charge is capped at the required lower level. The wait cannot renew during the same overage. If the battery cannot yield, stops responding or the rated current is exceeded, the normal car cut applies. A battery cut never grants an unmeasured car rise.

An idle car can restart once its minimum fits below the working fuse limit throughout the existing 35-second dwell. When battery charging would otherwise keep a running car one step short, its final step can use measured room below that working limit. No new setting.

Validation:

  • Regression tests fail on the released master: the small-overage case cuts the car and the minimum-only car cannot restart. The same tests pass here.
  • All control tests pass, including the field matrix and 12 new closed-loop cases: planned and Charge now, one and three phases, charger responses of 5, 40 and 120 seconds, small load step, forced stop and automatic recovery.
  • Tests cover every battery mode, self-tune, missing/offline/insufficient battery charge, stale meter, outstanding raises and an ignored battery reduction with a fixed fallback deadline.
  • GitHub CI passes, including full-stack tests, the Go race detector and both Linux targets.
  • make verify passes. Docker-only checks report skipped because no Docker daemon runs on this host.
  • New protocol scenario s18-16 passes: real FTW binary against pinned device-simulator (Sungrow Modbus, bound SDM630 and OCPP car), with concurrent charging, a small phase overage, a forced car stop and automatic restart. The complete short protocol set plus s15bat-16 passes on exact PR commit cb206f1: 10/10 scenarios, no known or failed criteria. The binary reports vcs.modified=false. The new case kept the car charging through the small step and restarted it after the forced stop; no fuse opened.

The simulator's recovery check now starts after actual fuse heat permits a restart and includes the existing battery-command settling window. This accounts for measured relief while recent battery raises still reserve room; the new scenario also checks recovery at fixed times.

Scope: based on shipping master, including #1870/#1871. Drafts #1789, #1782 and #1792 touch parts of the same control files. This fix keeps their broader fuse, phase-sign and two-phase changes for those PRs; it adds the issue-specific behavior and tests to the released path at the owner's request. No driver or UI change. No physical equipment used.

Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-27T07:25:32.970500Z cb206f1 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.

@frahlg
frahlg merged commit e293e2a into master Oct 27, 2026
22 checks passed
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.

Fuse guard sheds EV fully (min step 4140 W) while home battery grid-charges, and EV never restarts

1 participant