Skip to content

Site: don't apply battery priority to loadpoints with battery boost active#31790

Open
webalexeu wants to merge 1 commit into
evcc-io:masterfrom
webalexeu:fix/battery-boost-priority-soc
Open

Site: don't apply battery priority to loadpoints with battery boost active#31790
webalexeu wants to merge 1 commit into
evcc-io:masterfrom
webalexeu:fix/battery-boost-priority-soc

Conversation

@webalexeu

@webalexeu webalexeu commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #30541

Desired behavior

Battery boost deliberately drains the home battery into the vehicle and has its own soc floor via batteryBoostLimit (boost auto-disables when the battery soc drops below it). Therefore battery priority (prioritySoc) does not apply to a loadpoint with boost active: it may claim the power currently charging the battery. All other loadpoints keep respecting battery priority unchanged.

Problem

Below prioritySoc, sitePower() hides the power flowing into the battery (batteryPower, excessDCPower zeroed) and forces a 100W residual so loadpoints leave the surplus to the battery. This also starved boost-active loadpoints: with the battery charging at 2000W, the boosting loadpoint ramped at ~0.4A per cycle instead of ~9A and could stay stuck on 1 phase (see issue for the full calculation).

Solution (contained, per #30541 (comment))

  • sitePower() additionally returns the priority adjustment it applied (zeroed batteryPower + excessDCPower plus the residual override delta). Adding it back exactly reconstructs the unadjusted site power; the excessDCPower term self-corrects, so DC-only excess that no loadpoint can claim stays reserved for the battery.
  • site.update adds the adjustment back only for the loadpoint being updated when its boost is active. Loadpoints are updated one per cycle, so there is no double-counting with multiple boost loadpoints.

Covered by the new table-driven TestSitePowerPriorityAdjustment (charging above/below prioritySoc, discharging below), exercising the full sitePower path with mocked battery meters.

Known edge case: on the cycle where boost auto-disables (soc fell below batteryBoostLimit), the loadpoint may see one interval of unadjusted surplus before reverting — keeping the boost check out of sitePower is what keeps the change contained.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the bug Something isn't working label Jul 14, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@webalexeu
webalexeu marked this pull request as draft July 14, 2026 18:33
@andig andig added enhancement New feature or request bug Something isn't working and removed bug Something isn't working enhancement New feature or request labels Jul 14, 2026
@webalexeu
webalexeu marked this pull request as ready for review July 14, 2026 20:10
@mfuchs1984

mfuchs1984 commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

This looks nearly identical to my prototype, see master...mfuchs1984:evcc:fix/boost_below_prioritysoc

The only difference is that your add excessDCPower to priorityAdjustment, while my attempt reduces priorityAdjustment by excessDCPower. Don't know which one is right, should IMHO be understood before merging, and covered by a test.

…ctive

Below prioritySoc, sitePower hides the power charging the battery
(batteryPower, excessDCPower) and forces a 100W residual so loadpoints
leave the surplus to the battery. This also starved loadpoints with
battery boost active, which deliberately take priority over the home
battery (boost has its own soc floor via batteryBoostLimit).

sitePower now additionally returns the priority adjustment it applied;
site.update adds it back for a boost-active loadpoint, restoring the
unadjusted site power.

Fixes evcc-io#30541

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@webalexeu
webalexeu force-pushed the fix/battery-boost-priority-soc branch from 481552c to e4b4912 Compare July 17, 2026 10:01
@webalexeu

Copy link
Copy Markdown
Contributor Author

This looks nearly identical to my prototype, see master...mfuchs1984:evcc:fix/boost_below_prioritysoc

The only difference is that your add excessDCPower to priorityAdjustment, while my attempt reduces priorityAdjustment by excessDCPower. Don't know which one is right, should IMHO be understood before merging, and covered by a test.

Indeed, I've added a test yo cover it

@andig Can you have a look to see what you think ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BatteryBoost degraded performance below prioritySoc

3 participants