Skip to content

Fix sticky reserve floor on inverters without managed reserve SOC (e.g. SolisCloud)#3709

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-soliscloud-battery-soc-calculation
Draft

Fix sticky reserve floor on inverters without managed reserve SOC (e.g. SolisCloud)#3709
Copilot wants to merge 2 commits intomainfrom
copilot/fix-soliscloud-battery-soc-calculation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

On inverters where inv_has_reserve_soc = False (e.g. SolisCloud), the battery plan would permanently show a floor at whatever reserve value Predbat had last written — even after set_reserve_min was lowered — because the "reset" call adjust_reserve(0) was clamped to reserve_percent (the current elevated value) instead of reserve_min.

Mechanism: charge-freeze logic calls adjust_reserve(soc_percent + 1) → writes e.g. 80% to the reserve entity → freeze ends → adjust_reserve(0) clamps at reserve_percent = 80% → no write → stuck.

Changes

  • inverter.pyadjust_reserve(): Changed lower-bound clamp from self.reserve_percent to self.reserve_min.

    # Before — clamps reset call to the (possibly elevated) planning floor
    if reserve < self.reserve_percent:
        reserve = self.reserve_percent
    
    # After — clamps to the user-configured minimum, allowing the reset to take effect
    if reserve < self.reserve_min:
        reserve = self.reserve_min
  • inverter.py__init__(): Added a Warn: log when reserve_percent_current > reserve_min and the reserve is not Predbat-managed (inv_has_reserve_soc = False), explaining that the plan is constrained to the current inverter reserve and will auto-reset next execution cycle if set_reserve_enable is on.

  • tests/test_inverter.py: Updated test_adjust_reserve() to also set inv.reserve_min (required now that clamping uses it). Added reserve_percent parameter so the discrepancy scenario can be exercised. Added two new cases (adjust_reserve6/7) that directly assert the sticky-reserve bug is gone: reserve_percent=80, reserve_min=4/11, adjust_reserve(0) → must write 4%/11%, not 80%.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.octopus.energy
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --quick k/_temp/runtime-logs/command.sh (dns block)
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --quick (dns block)
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --test nordpool conf�� --get-regexp --global tnet/tools/git (dns block)
  • gitlab.com
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED (dns block)
  • https://api.github.com/repos/springfall2008/batpred/contents/apps/predbat
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --test inverter_self_test (http block)
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --list conntrack --ctstate INVALID,NEW -j DROP (http block)
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --test inverter (http block)

If you need me to access, download, or install something from one of these locations, you can either:

…dd warning log

Agent-Logs-Url: https://github.com/springfall2008/batpred/sessions/e08373e6-d20f-4e46-8a22-9372b56b5bdb

Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix battery SoC calculation issue in SolisCloud integration Fix sticky reserve floor on inverters without managed reserve SOC (e.g. SolisCloud) Mar 31, 2026
Copilot AI requested a review from springfall2008 March 31, 2026 08:30
Copy link
Copy Markdown
Contributor

@CraigCallender CraigCallender left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@CraigCallender CraigCallender left a comment

Choose a reason for hiding this comment

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

LGTM

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.

SolisCloud: Plan Never Shows Battery SoC Drop Below 80%

3 participants