Fix sticky reserve floor on inverters without managed reserve SOC (e.g. SolisCloud)#3709
Draft
Fix sticky reserve floor on inverters without managed reserve SOC (e.g. SolisCloud)#3709
Conversation
…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
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.
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 afterset_reserve_minwas lowered — because the "reset" calladjust_reserve(0)was clamped toreserve_percent(the current elevated value) instead ofreserve_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 atreserve_percent = 80%→ no write → stuck.Changes
inverter.py—adjust_reserve(): Changed lower-bound clamp fromself.reserve_percenttoself.reserve_min.inverter.py—__init__(): Added aWarn:log whenreserve_percent_current > reserve_minand 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 ifset_reserve_enableis on.tests/test_inverter.py: Updatedtest_adjust_reserve()to also setinv.reserve_min(required now that clamping uses it). Addedreserve_percentparameter 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 write4%/11%, not80%.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/home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --quick k/_temp/runtime-logs/command.sh(dns block)/home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --quick(dns block)/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/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/home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --test inverter_self_test(http block)/home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --list conntrack --ctstate INVALID,NEW -j DROP(http block)/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: