Repository navigation
Description
Feature request: forecast-aware battery reserve in real-time control (Balanced)
Current behavior (0.4.0rc1)
- Target SoC and Target Time are only used by the planner (
planner.py,_balanced_strategysplits slot excess 50/50). With Plan Influence = None this has no effect on real-time decisions. - In real-time control,
_power_for_optimizer()reserves battery charging power only for Battery First (battery_first_budget()). That reservation is a hard SoC threshold: excess is held back until SoC ≥ target, regardless of the solar forecast or the target time.
So in real time there are two options: Balanced/Appliance First, which never protects the battery target, or Battery First, which always protects it, even on a sunny morning when the forecast is far above what the battery still needs.
Request
A real-time mode that reserves battery charging only when the remaining forecast is not enough to reach the target SoC by the target time. Roughly:
needed_kwh = (target_soc - soc) / 100 * battery_capacity
usage_kwh = hours_until_target_time * avg_unmanaged_load_kw
reserve = forecast.remaining_today_kwh < needed_kwh + usage_kwh + buffer_kwh
reserve == False: appliances get the full excess (as Appliance First today).reserve == True: reserve charging power asbattery_first_budget()does today.- Missing forecast, SoC or capacity: fall back to the current Battery First behavior. Never assume a sunny forecast.
This could be the real-time behavior of Balanced, or a separate strategy, so existing setups don't change.
Why
This is how the original pyscript blueprint (nicorusti/ha-advanced-blueprints, _force_charge_battery()) behaved: min_home_battery_level acted as an end-of-day target with a forecast check and a fixed 2 kWh buffer, not as a start threshold. Users migrating from the blueprint lose this. Today they must choose between appliances never waiting for the battery and appliances always waiting until the target is reached.
Related: #44 (battery not prioritized), #58 (SoC ceiling for appliances).
Points to consider
- dmacwalter's fork tried a time-to-target feasibility gate (0.3.11–0.3.14) and removed it in 0.3.15. It was focused on cheap-tariff grid supplementation, and its simulation found regressions when the gate blocked appliances during cheap grid windows or while the battery was already being grid-charged. A solar-only reserve without tariff interaction should be simpler, but the same cases (grid charging active, minimum runtime pending) should be exempt.
- Hysteresis is needed so the reserve does not toggle every cycle when the forecast is close to the threshold (e.g. stay engaged until the margin is clearly positive again).
- The generic forecast provider gives only
remaining_today_kwh. That is enough for this check; hourly data is not required.
I can prepare a PR if the approach is acceptable.
Activity
MonsterD1 commentedon Nov 13, 2026
I opened #76 implementing this for Balanced: real-time reservation via the existing battery_first_budget() only when remaining_today_kwh - needed_kwh - usage_kwh falls below a 0.5 kWh buffer (1 kWh to release). Without an available forecast Balanced behaves as before. Base load (0.5 kW) and buffer are constants for now; happy to make them options or the behavior opt-in if you prefer.
Balanced: forecast-aware real-time battery reserve (InventoCasa#73)