Skip to content

feat(plan): show when live solar may charge the battery - #1485

Merged
frahlg merged 1 commit into
masterfrom
1482-plan-capture-field
Oct 1, 2026
Merged

frahlg merged 1 commit into
masterfrom
1482-plan-capture-field

Conversation

@frahlg

@frahlg frahlg commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Problem

Refs #1482.

Core already lets live solar beyond the plan charge the battery when the plan buys grid energy later at an import price above this slot's export price plus the minimum spread (livePVSurplusSoCCap → SlotDirective.LivePVSurplusSoCCap → pvSurplusAbsorbCap in dispatch). Without that permission, an idle or charging arbitrage slot sends surprise sun to the grid.

A beta tester saw exactly that (battery idle at 38 %, 3.5 kW to the grid, plan active) and could not tell from the UI why. The plan API did not expose the permission, so the Plan card could not say whether extra sun will be stored or sold.

Change

  • mpc.Action gains live_pv_surplus_soc_cap (0–1 SoC). Core computes it once when it publishes a plan, on every path: replan (every solver and the fallback), InstallPlan, and restore from a diagnostic. The DP shadow copies the plan, so it keeps the values.
  • SlotDirectiveAt reads the stored value instead of recomputing it, so the API shows the number dispatch uses.
  • The field is always sent, also when zero, so a client can tell "no permission" from a box that predates the field.
  • No change to dispatch rules or to which slots get permission. dispatch.go is untouched (open PRs feat(control): show command limits and measured response tiers #1474 and fix(control): mitigate PV-only export over limits #888 change it).

Verification

  • New: TestReplanStoresLivePVSurplusSoCCap (external optimizer, Core planner, Core fallback after an optimizer failure), TestReplanWithoutLaterGridChargeSendsZeroLivePVSurplusSoCCap, a restore test, and TestMPCPlanCarriesLivePVSurplusSoCCap (the /api/mpc/plan value equals the directive value for the same slot).
  • TestSlotDirectiveAt now publishes through InstallPlan, with the same assertions.
  • make verify passed on this commit.

#1486 is the Plan card change that reads the field. Either can merge first: the card says nothing about extra sun unless the plan carries the field.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 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-01T14:42:43.528742Z d316cc1 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.

Core already lets live solar beyond the plan charge the battery when the plan
buys grid energy later at a price above this slot's export price plus the
minimum spread (livePVSurplusSoCCap). The plan API did not say so, so the UI
could not tell a household whether extra sun will be stored or sold.

The SoC ceiling is now computed once when a plan is published, on every
solver path and on restore, and stored on each action as
live_pv_surplus_soc_cap. Dispatch reads the stored value, so the API shows
the number dispatch uses.

Refs #1482

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
@frahlg
frahlg force-pushed the 1482-plan-capture-field branch from d316cc1 to 7cc8173 Compare October 1, 2026 17:22
@frahlg
frahlg merged commit 082e5bb into master Oct 1, 2026
15 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.

1 participant