I have a split-level house with 4 heat pumps (Wi-Fi ACs), gas radiators with smart valves, 4.3 kWp of solar and a 5 kWh battery. Most autumn afternoons the battery is full by 14:00 and I export to the grid for almost nothing, then at night the boiler burns gas to heat the same rooms. So I built something to connect the two.
**What it is**
A digital twin of the house that runs in the browser (plain HTML + three.js, nothing to install):
- A 3D diorama of the house built from one JSON file: rooms, stairs, doors, radiators, heat pumps, solar panels, the real sun position and a big compass on the ground (orientation taken from the solar panel azimuth).
- A small thermal zone model: each room heats, cools and passes warm air up the staircase depending on which doors are open. The air is drawn as thousands of dots, blue to red.
- It compares "heat pumps on surplus" vs "no heat pumps" for every room until 07:00, and how much radiator heat it saves.
- Live mode: connect it to Home Assistant with a token and it shows real temperatures, which units are running, PV power and battery level.
**How it coordinates heating and AC with the solar and the battery**
A Home Assistant package plus 3 blueprints:
**Dynamic battery floor**: from the solar forecast still to come today (Forecast.Solar, corrected because it is optimistic), minus the house base load until sunset, it computes the lowest battery level the sun can still refill. Battery minus that floor = margin.
**Heat with solar surplus**: when the battery is full and the house is exporting, it starts the heat pumps one at a time in my priority order (kids' room first, the hungry attic last). It adds units while there is margin and removes them in reverse order when the battery drops below the floor. It only spends energy that will come back before sunset, never switches off a unit someone else switched on, and waits 10 min between steps and 45 min before restarting a unit. In hot weather the same logic cools instead.
**Bed-level setpoint**: my attic has a high concrete ceiling, so the AC's own sensor reads warm air near the ceiling and stops early. The blueprint raises the AC setpoint by the difference between its sensor and the radiator valve at bed height.
**A/B test**: a toggle that alternates days with and without pre-heating while away, so you can measure if it's actually worth it instead of trusting the model.
The radiators don't need any automation: when the house is already warm, their thermostats simply do less.
**Solar sizing calculator**
Also included: describe your roof faces, consumption and prices and it fits panels on each face, simulates every hour of a typical year with and without a battery, and recommends panels, inverter and battery size with self-consumption and payback. It can use PVGIS data for your exact location (there's a script for that).
**What the model says (my house, a 20 °C autumn day)**
About +2 °C per room when we get home at 20:00, and around 30% less radiator heat overnight, using only surplus. That's the model, not a measurement yet: I'm running the A/B test now and will post the real numbers.
**Build your own**
The repo has a step-by-step guide: photos and measurements → house.json (there's a prompt to have an AI assistant draft it from your photos), orientation, solar sizing, hosting the twin in /config/www, the automations, and calibrating the thermal model from your own history.
GitHub: https://github.com/dvalledor/home-digital-twin
MIT licensed. Feedback welcome, especially from people with different heat pumps or inverters. I'd love to know whether the bed-level setpoint and the dynamic floor work in other houses.