Victron solar · 32 kWh battery · AI planner

Solar that plans
the next two days.

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.

Victron GX · local Modbus linear programming Gemini as supervisor shadow mode

32 kWhDIY battery
15 minbetween re-plans
~78%measured grid round trip
22/30days Flux came out ahead
01 · The kit

Four boxes and a lot of watts

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.

Solar
2 × 6.3 kWp
Two roof planes facing opposite ways, so the house gets a long, flat day instead of one noon spike.
Inverter/charger
Victron MultiPlus 48/8000 + GX
Carries the whole house. The GX is the brain that the old controller and now the planner talk to.
Battery
2 × 16 kWh DIY
Self-built rack batteries with swappable cells, so wear costs pence per cycle rather than pounds.
Tariffs
cheap nights · paid exports
A time-of-use import tariff with a five-hour cheap window, plus a paid export tariff for what goes back to the grid.
02 · The Energy tab

Where every watt is going, and what it costs

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.

The tab reads the inverter live through Home Assistant. The costs come from the supplier's half-hourly data, and a small Python service on the Pi fetches them every thirty minutes. It's the same self-contained web-app pattern as the other panel tabs.

Real costs, not estimates

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.

Savings, measured

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.

A year of solar, drillable

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.

Two lessons that changed the numbers. First, export earnings have to come from measured energy times the rate in force that month, not from the bills: suppliers bank export credit and pay it out in lumps, so a twelve-month window of bills can over-count by more than a third. Second, self-sufficiency must only count grid power that went into the house. This battery also charges from the grid every night, and counting that made the house look 0% self-sufficient.
03 · Where the energy goes

The old controller was burning money politely

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.

Measured conversion losses

Solar → battery (DC)~96%
Inverting, mid load~93%
Charging from grid~90%
Grid → battery → grid~78%

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.

What that means

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.

04 · The planner

Maths makes the plan, AI checks it

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 maths decides; the AI supervises. Gemini sees the exact plan, both solar forecasts and the weather, and may only move three knobs within fixed limits: the reserve (10–40%), confidence in the solar forecast (0.6–1.2×) and expected household use (0.8–1.5×). Then the planner re-solves. On its first run it spotted that the forecast promised a sunny day while the weather said drizzle, and cut the solar estimate by 30%.

Guardrails in code

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.

A plan you can read

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.

Shadow first

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.

05 · The tariff trial

Three tariffs, one real house, every half hour

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.

Current tariff
Planned the same way, to show what the planner alone is worth.
What actually happened
The old controller's real behaviour on the real meter, the baseline.
Flux (three-rate)
Ahead on 22 of 30 days, and never needed a peak-rate unit.
Fixed renewal
Behind the three-rate tariff every single day of the backfill.

A month in seventy seconds

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 bug it caught

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.

What it showed. With the old controller's habits, the three-rate tariff would actually cost money. With a planner driving it, it's the clear winner. The trial keeps running until the decision is due, so the answer comes from the house's own data rather than a comparison site.
06 · Ask the house

The plan, by voice and on the phone

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.

“What's the energy plan?”
Luna: the planner's own one-paragraph briefing: what it expects from the sun, when it will charge from the grid and to what level, and what it's worth against running the battery with no plan.
“Which tariff is winning?”
Luna: the trial's current leader, by how much per day, and on how many days it came out ahead.

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.


Energy, at home

Measure first, then let the maths drive.

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.

Victron · local Modbus·LP planner · shadow·see it on the Wall panel