Kev's house runs on a Victron inverter, two roof arrays and a 32 kWh DIY battery. Home Assistant now shows all of it live on the wall panel, with the real costs from the energy supplier alongside. Behind that sits a new planner: every fifteen minutes it forecasts the sun and the house, and works out the cheapest way through the next two days. An AI checks its homework four times a day. It runs in shadow mode for now: it plans and explains, but doesn't touch the inverter yet. Meanwhile it quietly tests three electricity tariffs against each other on the house's real data.
Everything talks to Home Assistant over the local network. The Victron GX answers Modbus queries directly, so the live numbers never go near a cloud. The long history comes from Victron's own VRM portal, and the prices and bills from the supplier's API.
A new tab on the wall panel. The centrepiece is a live power-flow diagram: solar, grid, battery and home around a glowing core, each line moving faster as more power flows through it. Under it sit today's totals, and above it the money: standing charge, peak and cheap-rate imports, export credit and the net, over a week, a month or a year.
Every half hour's usage is multiplied by the rate that applied at that moment, so the cheap five-hour window and the peak day rate are costed exactly. Today's figures come from the inverter live, because the supplier's data lags by a day.
A savings card compares what the house actually paid with what it would have paid on a flat rate with no panels or battery. It also works out whether charging the battery overnight really earns its keep, using the energy the battery actually delivered.
The Solar tab gained a day / week / month / year view of solar against consumption, with self-sufficiency and the battery's charge overlaid, drawn from Victron's own history.
Before building anything new, we measured what the existing setup actually did. The old controller, a Node-RED flow running on the GX, looked busy and sensible. The data said otherwise: it exported every spare watt of solar once the battery passed about 17%, so by eleven at night the battery was nearly empty and the house bought peak-rate power before the cheap window opened. Every morning it also sold the night's cheap charge back to the grid, which at a realistic round trip barely broke even.
About 7.8 kWh a day was being lost in conversion, most of it from pushing grid power through the battery and back out again.
Store solar, don't grid-cycle for pennies. Solar going straight into the battery on the DC side loses almost nothing. Buying power, storing it and selling it back loses a fifth.
Spread the work. The charger and inverter are most efficient at moderate power. Pushing them above their 6.4 kW rating, as the old flow did, wastes the most.
Keep a reserve that fits the evening. Running the battery to the floor before the cheap window means paying peak rate for the last hour.
The new planner is a Python service on the Pi. Every fifteen minutes it reads the inverter live, pulls a solar forecast for each roof plane and the house's typical usage, and solves a linear programme over the next 36 to 48 hours in fifteen-minute slots. The result is when to charge from the grid, when to hold, when to export and when to let the battery carry the house, all at the lowest cost for the real tariff. The solve takes about half a second.
The AI can't write a schedule, only nudge the numbers it's allowed. The reserve never drops below 10%. Charge rates stay inside what the kit is rated for. If a forecast or the AI goes missing, the plan still stands on the maths alone.
The Energy tab draws the whole plan on one timeline: solar as an area, the house as a line, bars for grid charging and export, the battery's charge with its reserve, and the buy and sell prices underneath. Tap any slot to see why it does what it does.
Nothing is written to the inverter yet. When it goes live, the plan will be sent as a 48-slot schedule that the GX runs locally. If the Pi stops, the inverter carries on safely by itself.
Choosing a tariff usually means guessing. Here the planner runs a live experiment instead. Alongside the real tariff it keeps two virtual batteries: one planned for a flexible three-rate tariff, and one for the fixed deal on offer at renewal. Each plans with the same forecasts. Half an hour later, when the real metered data arrives, each virtual battery is settled against what the sun and the house actually did. Losses come from the measured efficiencies above, so no tariff gets a free lunch.
To avoid waiting weeks, the trial was backfilled over the last 30 days. It replayed each day using the forecasts that were actually available the day before, from a weather service that keeps its past forecast runs, rather than what the sun really did. The modelled losses matched the real meter to within 1%.
The backfill showed the planner buying peak-rate power on some evenings: it drained the battery to exactly the reserve, and an evening busier than forecast tipped it over. The fix was a safety margin, planning for 30% more household use in the most expensive slots. Peak buying fell by more than 80%, and the plan came out cheaper overall.
Home Assistant reads the planner's output into ordinary sensors: the action for right now, the next grid charge and whether the planner is healthy. So the rest of the house can use them. Luna, the local voice assistant, answers straight from them in well under a second, without calling the AI at all.
If the planner stops producing plans for half an hour, Kev's phone gets an alert, and an all-clear when it recovers. A plan nobody notices has gone stale is worse than no plan.
The flashy part is the AI. The part that matters is the measuring: real conversion losses, real half-hourly prices and real forecasts, so every decision is costed honestly. The planner will get its hands on the inverter only after weeks of shadow running show it beats what's there. Everything runs on the Pi at home; the only cloud calls are the forecasts, the supplier's prices and the AI's four check-ins a day.