I put together a small closed-loop system that automatically tunes how much my AlphaESS home battery charges overnight from the grid, based on what actually happens each night — the goal was simply to cut the monthly electricity bill without manually tweaking settings.
How it works:
- Each evening, an automation blends the next day’s solar forecast (Solcast) and the weather outlook into a tiered overnight charge target (40-90% range).
-
- Every morning it checks what actually happened: how low the battery got before sunrise, and how much was charged from the grid.
-
- Based on that outcome, it nudges the charge target up or down for future similar days (step_up/step_down, currently 5%/3%) — so it slowly converges toward “just enough” instead of always erring on the safe (expensive) side.
-
- A hard safety floor/ceiling (40-90% target, battery itself clamped 45-85%) makes sure it never risks running the battery flat before sunrise, no matter what the learning loop decides.
-
- A daily effect logger tracks whether each night was LOW (too conservative — battery barely used), HIGH (risked running low), or OK, so the whole thing is auditable in the HA logbook.
It’s 6 automations total, fully documented, MIT licensed:
GitHub - quanfuchen1981/ha-alphaess-battery-optimizer: Self learning Home Assistant automations for an AlphaESS home battery and solar system. · GitHub
- A daily effect logger tracks whether each night was LOW (too conservative — battery barely used), HIGH (risked running low), or OK, so the whole thing is auditable in the HA logbook.
Happy to answer questions if anyone wants to adapt it for their own inverter/battery setup.