Custom Home Assistant integration for forecasting home battery state of charge until the next solar takeover window and recommending when to run flexible loads.
This first version is recommendation-only. It does not directly control EV chargers, spa heating, or appliances.
Requires Home Assistant 2025.3 or newer for the programmable load UI.
- In HACS, open the menu and choose Custom repositories.
- Add
https://github.com/TheBarnHome/Energy-Monitoras repository type Integration. - Install Energy Monitor from HACS.
- Restart Home Assistant.
- Go to Settings > Devices & services > Add integration and search for Energy Monitor.
Copy custom_components/energy_monitor into your Home Assistant
custom_components directory, restart Home Assistant, then add the integration
from Settings > Devices & services.
- Battery SoC forecast at 30 minute resolution.
forecasttime-series attribute suitable for ApexCharts-style dashboards.- Baseload profile learned from historical home consumption.
- Optional grid export support. If export is unavailable or disabled, surplus solar that cannot be stored is treated as clipped.
- Configurable flexible loads via integration options.
- Flexible loads can be added as Home Assistant config subentries from the UI.
- Recommendation calendar for viable load windows.
energy_monitor.recalculateservice to force a refresh.
sensor.energy_monitor_battery_forecastsensor.energy_monitor_min_soc_before_solarsensor.energy_monitor_solar_takeover_timesensor.energy_monitor_recommendation_summarycalendar.energy_monitor_recommendations
The battery forecast sensor exposes:
{
"forecast": [
{
"datetime": "2026-05-28T22:30:00+02:00",
"soc_percent": 62.1,
"battery_energy_kwh": 6.21,
"solar_forecast_kwh": 0.0,
"baseload_kwh": 0.24
}
],
"actual_entity": "sensor.battery_soc",
"generated_at": "2026-05-28T22:29:10+02:00",
"resolution_minutes": 30,
"horizon_end": "2026-05-29T18:00:00+02:00"
}The configured solar forecast entity should expose a list attribute named one of
forecast, forecasts, or data. Each item should include a datetime-like key
(datetime, start, or period_start) and an energy-like value
(energy_kwh, solar_forecast_kwh, pv_estimate, estimate, or value).
Preferred setup: open the Energy Monitor integration in Settings > Devices & services, use the entry menu, and choose the subentry action to add a programmable load. Each load gets its own recommendation sensor.
Configure:
- Name and optional stable ID.
- Priority, where
1is evaluated first. - Duration in minutes.
- Either power in kW or total energy in kWh.
- Optional earliest start and latest end in
HH:MMformat.
The legacy JSON options format is still supported as a fallback:
[
{
"id": "ev",
"name": "EV",
"priority": 1,
"duration_minutes": 180,
"energy_kwh": 7.2,
"earliest_start": "22:00",
"latest_end": "08:00"
},
{
"id": "spa",
"name": "Spa",
"priority": 2,
"duration_minutes": 90,
"power_kw": 2.0
}
]For EVs, calculate energy_kwh from the car battery capacity and the difference
between current SoC and target SoC. A future version can read those entities
directly.
Run the pure Python forecast tests:
python3 -m unittest discover -s tests