Build a home solar forecast that reports its own error range

Ion Ionascu had Claude Code and Codex build an ML solar forecast from two years of Home Assistant data. Day-ahead error is about 2.9 kWh a day, level with Forecast.Solar, plus an 80% range.

Done withClaude CodeCodexinHome Assistant· Nov 12, 2026

What they did

Ion Ionascu, a software architect in south London with 10.4 kWp of panels on two roofs, wanted a forecast of how much solar was still to come each day so he could plan battery, export and hot-water choices. He set the goals and the data; Claude Code wrote most of the Python, and Codex later built an intraday correction. The service runs in k3s on a Raspberry Pi, pulls more than two years of production from Home Assistant and weather from Open-Meteo, combines a pvlib physics estimate with a gradient-boosted model per array, averages six weather models, retrains daily and exposes a web page, a CLI and an API that Home Assistant polls.

How it went

On held-out months the model was off by 2.91 kWh a day on days averaging 25 kWh, against 6.62 for raw physics. A review in claude.ai asked whether a simple monthly scale would do as well, and it got 95% of the gain; neither coding agent had tested that. Over 13 days it tied Forecast.Solar (2.02 vs 2.00 kWh) but its 80% range held on 10 of them. The intraday adjustment showed no clear gain. Codex tried eight model variants and kept none. Nothing acts on the forecast automatically yet.

Worth knowing

The sensor data was the hard part: inverter AC energy included battery discharge, one string logged impossible night readings, and Home Assistant and Open-Meteo stamp hours at opposite ends, an off-by-one trap. Ask the agent to compare against a dumb baseline, because two agents spent weeks refining a model without doing so.

Try it

With Claude Code· 4 parts to fill in

Build me a solar production forecast for my home from [my Home Assistant production history] and [a weather API such as Open-Meteo]. Start from a physics estimate for each array using [panel count, kWp, tilt and direction], then train a model on top of it. Clean the data first: drop night readings, impossible spikes and gaps, and check that both sources timestamp hours the same way. Test on whole held-out months and compare against raw physics and a simple per-month scale factor. Report the daily error and an 80% range, and expose an API that returns the energy still to come today. Stop and show me the evaluation table before you add anything that controls [my batteries or other devices].

Square brackets are the parts to fill in. The prompt is ours; the story is theirs.

Where they said it

Related