Skip to content

fix(execute): stop the export target draining the battery below the reserve - #4685

Open
romain-intel wants to merge 1 commit into
springfall2008:mainfrom
romain-intel:pr/export-reserve
Open

fix(execute): stop the export target draining the battery below the reserve#4685
romain-intel wants to merge 1 commit into
springfall2008:mainfrom
romain-intel:pr/export-reserve

Conversation

@romain-intel

Copy link
Copy Markdown
Contributor

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.

Comment thread apps/predbat/execute.py
- int: export target as a percentage of the battery
"""
target = int(self.export_limits_best[0])
if not self.set_reserve_enable:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

why if not set reserve enable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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)
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.

2 participants