Skip to content

fix(loadpoint): Charge now on a solar-only charger gets a fuse share - #1885

Merged
frahlg merged 1 commit into
masterfrom
d2-charge-now-on-surplus-only-charger
Oct 27, 2026
Merged

frahlg merged 1 commit into
masterfrom
d2-charge-now-on-surplus-only-charger

Conversation

@frahlg

@frahlg frahlg commented Oct 27, 2026

Copy link
Copy Markdown
Member

Item D2 of the stable plan.

Problem

A manual hold (Charge now) on a solar-only loadpoint was never a goal (controller_fuse_budget.go:55: goal = wantW > 0 && !cfg.SurplusOnly). An idle solar-only charger with no hold asks for its MaxChargeW, so the fuse budget sorts the two by ID.

Scenario: two solar-only chargers, 3p, steps 4140..11040 W, no PV surplus, EV fuse cap 8000 W, Charge now on b. Charger a sorts first and takes 6900 W of the cap, leaving 1100 W. That is below b's 4140 W minimum, so b gets 0 W with the reason fuse_limit on every tick. Charger a also orders 0 W, as it has no surplus, so nobody uses the cap.

Change

Treat every positive hold as a goal: goal = wantW > 0 && (held || !cfg.SurplusOnly). The hold lookup now runs once per loadpoint instead of twice. Only the sort order changes. The total cap, the per-phase room and applyFuseClamp still bound every order.

Tests

  • New surplus_hold_fuse_test.go, the repro test from the audit (caa-23). On master: orders map[charger-a:0 charger-b:0], FAIL. With the fix: orders map[charger-a:0 charger-b:6900], PASS.
  • cd go && go test -race ./internal/loadpoint/... -count=1: ok
  • go vet ./... and go build ./...: ok

Risk

Low. The fix can only lower other chargers' shares in favour of a held one, and every order stays inside the same fuse bounds. A solar-only hold with no deadline still ranks behind goals that have deadlines.

🤖 Generated with Claude Code

A manual hold on a SurplusOnly loadpoint was never a goal, so an idle
solar-only charger sorted ahead of it and reserved the EV fuse cap.
Treat every positive hold as a goal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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-27T13:16:17.622329Z 9765550 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 09ebd42 into master Oct 27, 2026
23 checks passed
@frahlg
frahlg deleted the d2-charge-now-on-surplus-only-charger branch November 11, 2026 09:16
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