Skip to content

Add an optional export energy budget: only export battery energy that came from PV (export_budget_mode) - #3

Closed
piomar123 wants to merge 6 commits into
mainfrom
pr/export-energy-budget
Closed

piomar123 wants to merge 6 commits into
mainfrom
pr/export-energy-budget

Conversation

@piomar123

@piomar123 piomar123 commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Brings springfall2008#5538 into the fork's main: optional export energy budget that only lets the battery export energy that came from PV (export_budget_mode: off | pv_origin | pv_equivalent).

The description, testing and review discussion live in the upstream PR. This PR uses the same branch (pr/export-energy-budget).

On the fork, main is upstream main plus the patches not yet merged upstream, rebased onto upstream main on every sync. When springfall2008#5538 is merged upstream, its commit is dropped from the fork's main during the next rebase.

Like springfall2008#5429 (fork PR #2), this changes the prediction kernel's PkContext and its ABI/parity numbers. With both on the fork's main, they need one combined numbering and rebuilt kernel binaries, in a separate commit after both.

🤖 Generated with Claude Code

piomar123 and others added 6 commits October 12, 2026 14:29
Some prosumer schemes only allow a household to sell energy its own PV
produced (e.g. Poland: grid energy stored in a battery may not be resold).
export_budget_mode in apps.yaml limits forced battery export to that energy:

- pv_origin: stored energy is split into a PV part and a grid part; battery
  output up to the on-site load draws the grid part first, only the PV part
  may be force exported.
- pv_equivalent: a bucket filled by PV production and drained by all export
  (capped by export_budget_cap_kwh, default the battery size).

The rule lives in export_budget.py and is mirrored by both prediction
engines (kernel ABI 8, parity 18). Each cycle the budget is seeded by
replaying 7 days of pv/export/import/load history (and battery SoC for
pv_origin). Export targets are raised so the inverter, which exports at full
power down to the target, can never sell more than the budget allows, both
when clipping a new plan and every cycle for the export running now.
predbat.export_budget publishes the budget now and over the best plan.

Off by default; with the mode off nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cross-built with build_kernel_cross.sh and zig 0.16.0 (as in CI) for ABI 8 / parity 18.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- export_budget_cap_kwh was read with an int default, so get_arg truncated
  7.1 to 7.
- soc_kw history for the pv_origin replay is now scaled by battery_scaling,
  as the live SoC is.
- export_budget_mode: off unquoted is YAML false; the schema accepts it.
- Docs: the replay length follows the history days_previous loads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… cap only bounds carried credit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… load in the same period (springfall2008#3973)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…edit, only battery export does

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@piomar123

Copy link
Copy Markdown
Owner Author

🤖: Closing: the fork no longer merges PRs into main. main is now an exact copy of upstream, and the default branch patched is rebuilt from the branches listed in tools/fork/branches.txt on fork-glue (see tools/fork/README.md there). This PR'''s branch, pr/export-energy-budget (springfall2008#5538), is in that list and merged into patched.

@piomar123 piomar123 closed this Oct 16, 2026
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