Home Assistant Energy Monitoring Setup — Solar, Battery & Grid
Home Assistant's built-in Energy dashboard is one of its most powerful features — but it only works as well as the data you feed it. Setting it up correctly for a solar + battery system takes a little thought. This guide shows you exactly which sensors to use, how to configure them, and how to get the most out of long-term energy data.
With properly configured energy monitoring you can see exactly: how much solar you produced, how much went to the battery vs direct consumption vs grid export, your real self-consumption percentage, and which appliances are consuming the most power. This data is the foundation for every useful solar automation.
The HA Energy Dashboard — What It Needs
Settings → Energy → Add sources. The dashboard needs specific types of sensors:
- Solar production: kWh produced today (cumulative, resets at midnight)
- Grid consumption: kWh imported from grid today
- Grid return: kWh exported to grid today
- Battery in/out: kWh charged into battery and kWh discharged from battery today
- Individual devices: kWh consumed by specific high-draw appliances (optional but very useful)
The critical point: these must be energy sensors (kWh), not power sensors (W or kW). HA can convert a power sensor to a Riemann sum energy sensor using a helper — but it's easier to use inverter integrations that already provide daily kWh totals.
SolaX Integration — What You Get
The SolaX HA integration (via HACS) provides these sensors automatically from a real SolaX X1-Hybrid system:
sensor.solax_today_s_solar_energy— daily PV production in kWhsensor.solax_today_s_import_energy— daily grid importsensor.solax_today_s_export_energy— daily grid exportsensor.solax_battery_1_power_charge— battery charge rate in W (real-time)sensor.solax_battery_soc— battery state of charge %sensor.solax_pv_power_total— total PV power in W (real-time)sensor.solax_measured_power— grid power (positive = import, negative = export)
Map the daily kWh sensors directly to the Energy dashboard. The real-time power sensors are what you use in automations.
Shelly EM — When You Don't Have Inverter Integration
If your inverter doesn't have a HA integration, or you want independent monitoring, a Shelly EM with two clamp sensors at the distribution board gives you:
- Real-time power draw from/to grid
- Cumulative kWh (Shelly tracks this internally)
- Local MQTT — no cloud, instant updates
Two clamps: one on the main feed in, one on the solar feed. HA can calculate consumption, import, and export from these two values. Configure Shelly local MQTT in the Shelly app, then add the MQTT integration in HA.
Creating Energy Sensors from Power Sensors
If you have a real-time power sensor (W) but no cumulative energy sensor (kWh), create one using HA's Riemann Sum integration helper:
- Settings → Helpers → Create Helper → Riemann Sum
- Input: your power sensor
- Unit: kWh
- Integration method: Left Riemann sum
- Precision: 2
This creates a cumulative energy sensor that the Energy dashboard accepts.
Long-Term Statistics and CSV Logging
HA stores long-term statistics automatically for energy sensors. But for detailed analysis, logging to CSV via a Node-RED flow gives you much richer data with custom columns and timestamps.
A production Node-RED flow for solar logging captures 78 columns every 60 seconds including: battery SOC, charge rate, PV power per string, grid power, AC state, inverter mode, outdoor temperature, time of day — everything needed to diagnose issues and tune automations.
The CSV is stored at /homeassistant/www/solar_log.csv and accessible via the HA media browser for download and analysis in Excel.
Individual Appliance Monitoring
For the highest-value appliances, add individual power monitoring:
- Geyser: Smart plug with power monitoring on the geyser element circuit switch. Sonoff S31 flashed with ESPHome is ideal.
- Pool pump: Smart plug or in-wall relay with power monitoring.
- EV charger: Most modern EV chargers have power monitoring built in and a HA integration.
- Air conditioner: AC units don't have a plug to add a smart plug. Use a Shelly EM clamp on the AC circuit breaker for accurate monitoring.
The HA Recorder — What to Exclude
With 869 entities, the HA database grows fast. Exclude high-frequency entities that you don't need long-term history for to keep the DB manageable:
# configuration.yaml
recorder:
purge_keep_days: 30
exclude:
entity_globs:
- sensor.solax_battery_1_power_* # keep charge only
- sensor.*_rssi
- sensor.*_lqi
- sensor.*_linkquality
entities:
- sensor.time
- sensor.date
Ready to plan your HA solar automations?
Once your energy monitoring is in place, the Solar Automation Planner generates the automations that actually use this data — with working YAML for your specific setup.
🏠 Open the HA Planner