Feature: "Solar first" optimizer strategy for self-consumption
Is your feature request related to a problem? Please describe.
For home battery systems with flat feed-in rates (no dynamic tariff spread), the MILP optimizer has no economic incentive to prefer battery charging over grid export. Solar surplus gets exported at peak power while the battery charges only as a side effect of the cost tiebreaker (attenuate_grid_peaks). This is the wrong answer for installations where self-consumption matters more than cost arbitrage. It also does not help with feed-in power caps at the grid connection point (e.g. the German 70% rule), where the goal is to keep export below a fixed ceiling by diverting surplus into the battery.
Describe the solution you'd like
Two complementary features:
-
charge_profile: SoC-dependent charge power limits (CC-CV taper). The optimizer currently treats
c_maxas constant. In reality, the BMS reduces charge current at high SoC. AchargeProfile: lifepo4_conservativeconfig option per battery models the taper curve, making schedules feasible above 80% SoC. -
Solar first strategy: Alternative to the MILP. Instead of minimizing cost, it finds the flat export ceiling that charges the battery to target SoC while reducing grid export peaks. All active charging slots reduce the forecasted feed-in power by the same amount. Activated via
OPTIMIZER_STRATEGY=solar-firstenv var. The UI adapts accordingly.
Both are fully backwards compatible (opt-in only). I have implemented, tested, and deployed both features in production on a 34 kWp / 42.58 kWh LiFePO4 system. Built with AI assistance (Claude). Changes span evcc-io/optimizer (4 files) and evcc-io/evcc (7 files). PRs are ready.
Describe alternatives you've considered
The existing attenuate_grid_peaks charging strategy helps but only acts as a tiebreaker when multiple schedules have the same cost. It does not actively optimize for self-consumption or flat export. For flat-rate systems, every schedule has the same cost, so the tiebreaker is the only thing steering the battery, which produces suboptimal results.
Additional context
Charging plan with Solar first active. The grid power line (grey) is flat during active charging. CC-CV taper visible as charging power decreases toward the end of the charge window.
The changes span two repositories. I would appreciate guidance on how to structure the PRs given the dependency (evcc needs the new optimizer version).
We briefly met at MCH2022 and WHY2025. Happy to discuss on a call, in German if easier.
Thanks for the detailed writeup and for sharing the production numbers on the 34 kWp / 42.58 kWh system.
This confirms both features build on the separate evcc-io/optimizer module (currently pinned in go.mod at github.com/evcc-io/optimizer v0.0.0-20260613102250-473d3906e657, consumed via core/site_optimizer.go), so this is a two-repo change rather than something containable in a single PR here.
Suggested path forward:
- Open the
charge_profileandsolar-firststrategy PR againstevcc-io/optimizerfirst, sinceevcc-io/evcconly consumes tagged versions of that module. - Once merged/tagged there, open the follow-up PR here (
go.modbump + the 7 files you mention: presumably UI/config wiring incore/site_optimizer.go,assets/js/components/Optimize/*,core/optimizer.md, etc.). - Please split "charge_profile" (BMS taper modeling) and "solar-first strategy" (new optimization objective) into separate PRs on the optimizer side if feasible — they're logically independent and easier to review/merge separately.
This is a feature proposal, not a bug, so I'm labeling it enhancement. A maintainer will need to weigh in on the two-repo PR sequencing and whether OPTIMIZER_STRATEGY=solar-first is the right activation mechanism (vs. per-site config).
🤖 Generated with Claude Code
Thank you for the detailed guidance. I will submit the pull requests accordingly.
Please find attached screenshots from various tools taken later today, which confirm that the code functions as expected.
I hope these are helpful for your review. Should you have any questions or require further adjustments, please do not hesitate to let me know.
Thank you very much for your time and support.
In this setup V balance is set to 3.4V.
I'm not sure why we need this given we have https://github.com/evcc-io/optimizer/pull/96?