Home battery + solar optimisation
Data
Energy
Forecasting
Optimisation
This project is a dive into 2 years of hourly household energy data (solar production, consumption, import/export, and battery charge/discharge). The aim is to answer actionable questions that actually change behaviour: when to charge overnight, how to avoid peak pricing, and how objectives (cost vs independence vs carbon) lead to different decisions.
Key idea: overnight charging should be driven by a day-ahead view of risk: how likely tomorrow is to have a deficit during the expensive and PV-poor hours. Even a simple, explainable forecast (historical averages by month + weekday + hour) is enough to produce a sensible baseline recommendation.
Electricity Tariff
Peak pricing is 16:00–19:00 (highest import rate), which heavily rewards shifting demand away from that window.
Build-time parsed dataset
Hourly resolution
Tariff-aware cost modelling
Net electricity cost
£97
Import cost minus export revenue (excludes standing charge).
Import cost
£995
Total spend on grid energy, priced by the time-of-day tariff.
Export revenue
£898
Total income from exporting energy back to the grid.
Self-sufficiency
50%
Fraction of consumption not served by the grid: 1 − (import / load).
PV self-consumption
43%
Fraction of PV used on-site (directly or via battery): 1 − (export / PV).
Peak cost (16:00–19:00)
-£185
Net cost incurred only during the 16:00–19:00 peak tariff window.
Daily costs and energy
Typical day profile (hourly averages)
Assumptions
- Timestamps are treated as local clock time for applying tariff windows; the CSV has no explicit timezone.
- Costs use the fixed import/export p/kWh you provided and do not include standing charges.
- Battery capacity is estimated from a state-of-charge proxy integrating (charged − discharged); it is an approximation.
- PV self-consumption is computed as 1 − (export / production); it does not attempt to separate PV→battery vs grid→battery charging sources.
Day-ahead planner
Real solar forecast input
Tomorrow assumptions
If not provided, total PV is distributed by your historical PV shape.
Overnight charging (02:00–05:00)
Recommendation is the amount to charge during the cheap window so you can discharge later during deficit hours.
5.62 kWh
Expected deficit tomorrow: 5.06 kWh (peak 16–19: 0.86 kWh)
Estimated savings: £0.49 (avoids £1.41 of expensive import by buying £0.92 at cheap rate)
- This is a day-ahead optimiser: it uses your tomorrow PV forecast + an expected load profile to decide how much cheap energy to shift into higher-priced hours.
- It greedily allocates battery energy to the most expensive deficit hours first (typically 16–19 peak, then evening).
- The result is capped by your cheap-window charge power and usable battery capacity.
Next questions
- Peak avoidance: how much battery power/capacity is required to reliably hit zero import from 16:00–19:00?
- Carbon optimisation: repeat the analysis using half-hourly UK grid intensity to decide when grid-charging is ever justified.