Virtual Solar

Table of Contents
A Home Assistant custom integration that simulates a solar panel and battery system from sensors you already own. Point it at an ambient light (lux) sensor and a whole-house power meter, and it produces live estimated output, a virtual battery that charges and discharges over time, and a dashboard you can paste in with one service call. Built to answer “would a balcony solar setup actually be worth it?” before spending any money.
Requires Home Assistant 2024.1.0 or later. Distributed as a HACS custom repository.
Features #
- Lux-to-Watts estimation: solar output computed live from
(lux / 120) × panel_wattage × panel_count × system_efficiency. - Integration-owned virtual battery: a
numberentity that ticks every minute applying(solar − house)capped at the configured charge/discharge rates, clamped to capacity, and survives HA restarts. - Live-editable sliders for panel count, panel wattage, battery capacity, and system efficiency, so you can play “what if I had two panels?” from the dashboard in real time.
- Six derived sensors: estimated output, battery status (Charging / Discharging / Full / Empty / Holding, with action-over-condition priority), charge rate (signed, with directional icon), percentage, human-readable time-to-full, and grid export (surplus that would have flowed to the grid when the battery is full or solar exceeds the charge rate).
- Discharge control switch: toggle whether the battery discharges to cover the house or holds its charge. Automate it against a time-of-use tariff (grid overnight, battery daytime) or hold the battery while an EV is on the wall.
- Profiles: preset configurations for Anker SOLIX SOLARBANK 3 E2700 Pro, EcoFlow DELTA 2, generic 800 W balcony kits, and generic 5 kW rooftop systems. Contributors can add more via a one-block YAML PR.
- Asymmetric charge/discharge rates for kits like the EcoFlow DELTA 2 with separate input and output limits.
- Multiple setups in parallel: install the integration more than once with different setup names to A/B compare configurations (e.g. 1-panel vs 3-panel) against the same real lux and house sensors.
- Auto-generated dashboard via the
virtual_solar.get_dashboardservice. With multiple setups, one tab per setup in a single dashboard. Copy the response, paste into a new dashboard’s Raw configuration editor, done. - HACS-installable with full UI configuration, no YAML editing required.

Installation #
HACS (recommended) #
- In HACS → Integrations → menu → Custom repositories.
- Add
https://github.com/virtuallytd/ha-virtual-solarwith category Integration. - Find “Virtual Solar” in the HACS list, install it, restart Home Assistant.
- Settings → Devices & Services → Add Integration, search for “Virtual Solar”.
Manual #
Copy custom_components/virtual_solar/ from the latest release into your Home Assistant config/custom_components/ directory, restart HA, then add the integration via the UI.
Quick Start #
The setup wizard has four steps:
- Setup name + Profile: name this setup (used as the device title and entity-ID prefix), then pick a preset for a known kit, or “Custom” to fill everything in manually. Add the integration again later with a different name to run parallel setups.
- Sensors: choose your lux sensor (
device_class: illuminance) and house power sensor (device_class: power, reporting in W, or kW from v0.8.2). - Solar panels: initial values for panel count (up to 60) and wattage. Edit live via the dashboard later.
- Virtual battery: capacity (kWh), max charge rate (W), max discharge rate (W), system efficiency (%).
After setup, Configure on the integration card only changes the sensors and the max charge and discharge rates. Panel count, panel wattage, battery capacity, and system efficiency are changed with the sliders on the dashboard.
After install, call Developer Tools → Actions → Virtual Solar: Get dashboard YAML, copy the entire response, and paste it into a new dashboard’s Raw configuration editor.
Under the Hood #
Pure Python, no external runtime dependencies. The integration creates one logical device with sensors driven reactively off state changes (no polling), one minute-interval timer for the battery ticker, and a single service that returns a pre-populated Lovelace YAML. State persists across HA restarts via RestoreEntity. Source is around 700 lines of straightforward HA platform code: no clever tricks, contribute-friendly.
Links #
Blog Posts #
- Simulate Solar & Battery in Home Assistant: the original post.
- Virtual Solar: multi-instance, grid export, and community-driven changes: what’s new since the initial release.
License #
MIT.