fix(execute): stop the export target draining the battery below the reserve - #4685
Open
romain-intel wants to merge 1 commit into
Open
fix(execute): stop the export target draining the battery below the reserve#4685romain-intel wants to merge 1 commit into
romain-intel wants to merge 1 commit into
Conversation
| - int: export target as a percentage of the battery | ||
| """ | ||
| target = int(self.export_limits_best[0]) | ||
| if not self.set_reserve_enable: |
Owner
There was a problem hiding this comment.
why if not set reserve enable?
Contributor
Author
There was a problem hiding this comment.
My understanding (and correct me if this is wrong) is that:
- when set_reserve_enable, there is a separate place that PredBat writes the "floor" (ie: the reserve to maintain)
- a planned limit of 0 means "discharge as much as you are allowed to"
- when PredBat has a reserve register to write to, this is fine (ie: the reserve will act as the "floor" of export.
- therefore, we only need to set this when there is no separate floor. If there is a floor, there is no need to change behavior.
…eserve An export limit of 0 means "empty it as far as you are allowed", and the reserve is what says how far that is. discharge_soc resolves it that way when deciding how far to actually export, but the raw unclamped limit was handed to adjust_export_immediate and adjust_battery_target_multi. On an inverter whose service maps that target onto a device reserve, the result is an instruction to drain the battery flat. Observed on a Powerwall driven by service hooks: Predbat logged "current SoC 10.719kWh and target 1.35kWh" - correctly targeting the 5% reserve - while simultaneously writing backup_reserve 0 to the device, which then discharged past 5% towards empty. Extracted as export_target_soc_percent() so the rule is named and testable. The clamp applies only when set_reserve_enable is off. Where Predbat owns the reserve register that register already enforces the floor and the two are independent, so raising the target there would change long-standing behaviour for no benefit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> (cherry picked from commit bdcbb2c3d58a3cb04062db7d68bffab11c6ade3e)
romain-intel
force-pushed
the
pr/export-reserve
branch
from
August 25, 2026 04:36
810a000 to
a4ebc9b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An export limit of 0 means "empty it as far as you are allowed", and the reserve is what says how far that is. discharge_soc resolves it that way when deciding how far to actually export, but the raw unclamped limit was handed to adjust_export_immediate and adjust_battery_target_multi. On an inverter whose service maps that target onto a device reserve, the result is an instruction to drain the battery flat.
Observed on a Powerwall driven by service hooks: Predbat logged "current SoC 10.719kWh and target 1.35kWh" - correctly targeting the 5% reserve - while simultaneously writing backup_reserve 0 to the device, which then discharged past 5% towards empty.
Extracted as export_target_soc_percent() so the rule is named and testable. The clamp applies only when set_reserve_enable is off. Where Predbat owns the reserve register that register already enforces the floor and the two are independent, so raising the target there would change long-standing behaviour for no benefit.