Fix charge/discharge curve spam warnings and calculate_yesterday soc_kw_h0 fallback#3937
Draft
Copilot wants to merge 3 commits into
Draft
Fix charge/discharge curve spam warnings and calculate_yesterday soc_kw_h0 fallback#3937Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Agent-Logs-Url: https://github.com/springfall2008/batpred/sessions/b3767f10-efbb-46dc-a58a-c1e7a8fb1a9e Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com>
…k in tests Agent-Logs-Url: https://github.com/springfall2008/batpred/sessions/b3767f10-efbb-46dc-a58a-c1e7a8fb1a9e Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix battery charge/discharge curve fitter warnings in v8.39.4
Fix charge/discharge curve spam warnings and calculate_yesterday soc_kw_h0 fallback
May 17, 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.
Two regressions from v8.39.4 that fire every cycle: the battery curve fitter warns continuously when no full-rate charge-to-full event exists in history (normal in cost-optimised operation), and
calculate_yesterdayhard-exits whensoc_kw_h0HA history is unavailable, leavingsavings_yesterday_*permanentlyunavailableandsavings_total_*cumulatives frozen.Charge/discharge curve warnings (
inverter.py,execute.py)The fitter requires a "charge to 100% at max rate" event in the history window. Under cost-optimised Predbat operation the battery rarely if ever hits 100%, so no qualifying event is found — and
computed_charge_curvewas never setTrueon failure, causingfind_charge_curveto be called (and warn) every single cycle.inverter.py: Downgrade "no full rate cycle found" fromWarn→Info. This is expected behaviour, not a configuration error.execute.py: After a failed curve search whenbattery_charge_power_curve_autois off, setcomputed_charge_curve = Trueto stop retrying every cycle. Same for discharge.calculate_yesterdaysoc fallback (output.py)calculate_yesterdaywas re-fetchingpredbat.soc_kw_h0from HA and doing an earlyreturnon failure — blocking the entire savings pipeline.fetch.pyalready fetches and parses this intoself.soc_kwh_historyevery cycle; there's no need to re-query HA.self.soc_kwh_history(in-memory, already populated byfetch.py) as the primary SoC data source.soc_kwh_historyis empty, fall back to a fresh HA history fetch.Infoand substitutesoc_yesterday(fromsavings_total_soc) as a constant rather than bailing out — savings computation continues with a degraded but non-zero SoC estimate.Tests
Added
_test_soc_kw_h0_fallbacktotest_calculate_yesterday.pywith two sub-cases:soc_kwh_historyempty and HA history absent → function runs to completion (no early exit).soc_kwh_historypopulated, HA history absent → function uses in-memory data and setssavings_last_updated.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(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 --quick(http block)/home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --test find_charge_curve --test calculate_yesterday(http block)/home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --test calculate_yesterday(http block)If you need me to access, download, or install something from one of these locations, you can either: