Skip to content

Repository files navigation

Sourceful Energy Lab

Open the demo

An interactive home energy demo with the real Energyplan 0.2.1 forecasting and optimization worker running locally in WebAssembly. The browser renders a 3D home and simulates its devices, meter, power flows and control loop. No backend, account or hardware connection is needed.

Run

Requires Node.js 24 and npm.

npm ci
npm run dev

Open http://localhost:5178. For a static build:

npm run build
npm run preview

The built dist/ folder works under a subpath, including GitHub Pages. Assets, fonts, data and the WASM worker ship with the demo; the running app does not fetch weather, prices or household telemetry from external services.

Explore

  • Rotate the home, zoom and open Visa energiflöden for an illustrated cutaway with heat pump, AC, kitchen, sauna and household equipment. Follow power in kW and current in A through two DC solar strings and a DC battery into Sungrow, then through its shared AC port to the distribution board, grid, household and Easee. The wiring diagram shows the same flows.
  • Change season, weather, starting time and speed. Snow, fallen and falling leaves, blossoms, clouds, rain, sun, moon and lighting change in the scene. A small bird flies between the trees; a cat sometimes crosses the garden.
  • Change the panel count, battery capacity, battery power, inverter power and main fuse. The 3D equipment updates immediately; hardware changes start a fresh run so energy totals do not mix different installations.
  • Change household presence, turn appliances on and inject a passing cloud or a P1 outage. Compare requested power, accepted power and device response.
  • Try Sourceful coordination, ordinary inverter self-consumption or unmanaged EV charging. The stress button adds oven, sauna and AC demand. A modelled overload can open the fuse and leave the site without power until reset.
  • Two independent baseline simulations follow the same inputs and start states as the selected run. Compare cost, EV charge, remaining battery energy, peak phase current and fuse state. Cost alone is not a savings claim.
  • Inspect Så tänker plannern, the event log, forecast and plan chart, then export the run as JSON.

Home and equipment

The procedural house follows owner-provided reference images. The images are not included. Defaults supplied by the owner: 9 kWp south-facing solar, an 8 kW Sungrow inverter, 10 kWh / 5 kW battery, 11 kW Easee AC charging and a metallic blue Tesla Model Y Juniper.

Example assumptions: 24 panels at 375 W, 35 degree roof slope, 75 kWh usable EV capacity, 3 x 20 A fuse, 48% initial stationary charge, 42% initial EV charge, 80% EV goal at 07:00. These are editable. Room positions and appliance shares are illustrations, not a surveyed floor plan or submeter measurements.

Data and model

public/data/household-profile.json contains a median profile for 96 local quarters, derived from 20,141 FTW household-load samples over seven days ending 7 September 2026, excluding EV charging. It is a repeated day template, not an uninterrupted energy integral or a replay of one measured day. No raw site telemetry, box address, device ID, credential or photograph is included.

public/data/{season}.json contains 19 days of historical hourly weather per season from Open-Meteo / ECMWF for regional Kalmar coordinates, and three days of SE4 spot prices from Elprisetjustnu.se / ENTSO-E. Radiation is mapped from the preceding-hour interval. scripts/fetch-weather.mjs refreshes these public source files. Weather data is CC BY 4.0: Open-Meteo historical API, Elprisetjustnu API.

The original worker trains on 14 simulated days shaped by the measured load profile and historic weather. Complete subsequent quarters update its state. Weather forecasts are imperfect scenarios derived from historical weather, not archived issued forecasts. Known presence and manually selected loads sit above the learned base profile. This demonstrates adaptation; it does not measure forecast accuracy on a held-out cohort.

The simulation uses 1, 5, 15 or 60 second steps, quarter-hour planning and a 24 hour horizon. Battery and EV response lag and conversion losses affect actual energy. The plant enforces battery limits, AC power balance and the hybrid inverter's shared 8 kW output. The Sourceful demo controller additionally checks phase headroom and stops new dispatch after 10 seconds without P1.

The public demo validates proposed plans before simulated dispatch. It does not contain FTW Core's full safety system. In this worker version the shared PV/battery AC limit is enforced by the fast simulated controller, not the joint optimizer model. The fuse uses an illustrative heating integral, not a manufacturer's time/current curve. Large uncontrolled loads can trip it even with Sourceful coordination. No grid-forming backup is modelled.

Seasonal snow cover is an illustration, not measured cover; snow on modules does not yet reduce the solar model. Solar production uses historical panel irradiance, temperature derating and inverter clipping, with no surveyed shading model. The scene's south-facing roof, sun path and rotating compass share the same coordinate system.

The DC view uses the plant's existing lumped loss factors: 6% for solar and 4% in each battery direction. It does not add losses again or claim a measured Sungrow efficiency curve. The planner and daily chart use AC-equivalent power. Current is calculated from power and voltage, with 230 V phase-to-neutral and unity power factor on AC. Two series solar strings split the panels evenly. Their reference voltages, 443 V and 411 V, come from a box reading on 8 September 2026; 12 panels per string is an assumption. Panel count scales string voltage. Battery voltage defaults to an editable 200 V example. The model does not enforce MPPT voltage limits or simulate reactive power. These are simulated currents, not a live hardware feed. Zap receives P1 data, not electrical power through the illustrated data link.

Checks

npm run verify
npx playwright install chromium
npm run test:browser

Unit tests exercise the real WASM handshake, optimizer, forecasts and plan validation, AC/DC energy balance, device response, stale P1, phase limits, hybrid output and fuse behaviour. Browser tests use the production build, including a full-day replay, missing-WASM recovery, mobile controls, seasons, cutaway loads, hardware changes and overload recovery.

Source and license

The demo application, procedural scene and its tests are MIT licensed. Browser and font dependency notices are in public/THIRD-PARTY-NOTICES.txt. The Energyplan engine is proprietary and distributed as an unmodified compiled worker, with its binary license, third-party notices, Rust runtime notices and public integration schemas in public/engine/.

public/engine/manifest.json records the exact private source commit, artifact hashes and compiler. Engine source, tests, algorithms and build tools stay in the private srcfl/energyplan repository. This repository contains only the public integration and compiled distribution, not that source code.

About

Sourceful Energy Lab: a 3D home, real Energyplan WebAssembly, forecasts and energy control simulations

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages