If an ESPHome power or energy sensor works perfectly in Home Assistant but does not appear in the Energy dashboard, the problem is usually metadata rather than the ESP32. Home Assistant only offers sensors whose unit, device class, state class and long-term statistics are compatible with the type of energy data you are trying to add.
The most common mistakes are simple: trying to add watts where Home Assistant expects accumulated energy, using measurement on a kWh total, changing a sensor from W to kWh after statistics already exist, or forgetting that a daily-reset sensor behaves differently from a lifetime meter.
This guide starts with the quickest checks, then covers ESPHome YAML, power-to-energy conversion, pulse meters, statistics errors and what to do when a sensor still refuses to appear.
Quick Checklist: Why Your Sensor Is Missing
| Problem | What Home Assistant expects |
|---|---|
| Energy sensor missing | device_class: energy plus state_class: total or total_increasing |
| Power sensor missing | device_class: power plus state_class: measurement |
| Wrong unit | Supported energy unit such as Wh or kWh; power such as W or kW |
| Entity is not a sensor | Energy dashboard selectors require a sensor entity |
| Sensor used to have another unit | Check long-term Statistics for a metadata/unit conflict |
| Daily energy resets | Use a compatible total state class and allow Home Assistant to handle the reset correctly |
| Watts used as kWh | Convert/integrate power over time rather than only renaming the unit |
| No long-term statistics | Sensor needs a valid state class and no statistics error |
Current Home Assistant documentation specifically says to check the entity’s attributes and then the Statistics troubleshooting page if an otherwise valid sensor does not appear in an Energy selector.
Power and Energy Are Not the Same Thing
This is the most important distinction in energy monitoring:
Power = instantaneous rate of energy use
Unit: W or kW
Energy = accumulated quantity over time
Unit: Wh or kWh
A kettle might draw 2000 W while it is heating. If it runs at 2000 W for 30 minutes, it uses approximately 1 kWh of energy.
Changing a Home Assistant sensor’s unit from W to kWh does not convert power into energy. The numerical value must be integrated over time or obtained from a real accumulated-energy register.
Correct ESPHome Metadata for a Power Sensor
An instantaneous power sensor should normally look like this:
sensor:
- platform: template
name: "House Power"
id: house_power
unit_of_measurement: "W"
device_class: power
state_class: measurement
accuracy_decimals: 0
lambda: |-
return 742.0;
The important combination is:
unit_of_measurement: W
device_class: power
state_class: measurement
Home Assistant stores min, max and mean long-term statistics for measurement sensors. A power sensor is not an ever-increasing counter, so do not mark watts as total_increasing.
Correct ESPHome Metadata for an Energy Sensor
A cumulative energy sensor should use an energy unit and a total state class:
sensor:
- platform: template
name: "House Energy"
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
accuracy_decimals: 3
Home Assistant’s Energy dashboard accepts energy sensors with:
device_class: energystate_class: totalorstate_class: total_increasing- A supported energy unit such as Wh or kWh
total vs total_increasing: Which Should You Use?
Older examples often recommend total_increasing for every electricity meter. Current Home Assistant developer guidance is more precise.
| Sensor behaviour | Best state class |
|---|---|
| Lifetime meter that never resets | total |
| Counter may reset to zero, otherwise only increases | total_increasing |
| Daily/monthly counter that resets at known cycle | total_increasing is commonly used |
| Net total can legitimately rise and fall | total with suitable reset semantics |
Both total and total_increasing are valid for the Energy dashboard. ESPHome’s own energy examples frequently use total_increasing, especially for pulse totals and daily energy sensors.
The important thing is that the state class matches the behaviour of the number. If a supposedly monotonically increasing sensor randomly falls from 12,543 kWh to 17 kWh because the ESP32 rebooted and lost its total, Home Assistant has to interpret that discontinuity as a reset.
If You Only Have Watts, Create an Energy Sensor
Many ESPHome devices expose instantaneous power but not accumulated energy. You cannot use a unit rename to solve that. Integrate the power over time.
ESPHome’s integration sensor can create a lifetime-style energy total directly on the ESP32:
sensor:
- platform: template
name: "Heater Power"
id: heater_power
unit_of_measurement: "W"
device_class: power
state_class: measurement
- platform: integration
name: "Heater Energy"
sensor: heater_power
time_unit: h
restore: true
unit_of_measurement: "Wh"
device_class: energy
state_class: total_increasing
If you want kWh instead of Wh, either configure the integration accordingly or scale the output by 0.001.
Home Assistant also has its own Integral/Riemann-sum helper. If the raw power sensor already exists reliably in Home Assistant, creating the energy sensor there is perfectly valid. If you prefer the ESP32 to continue integrating while Home Assistant is restarting or updating, ESPHome-side integration has an advantage.
ESPHome total_daily_energy: When It Makes Sense
ESPHome’s total_daily_energy helper integrates a power sensor and resets the result every day. A typical configuration is:
sensor:
- platform: total_daily_energy
name: "Daily Energy"
power_id: house_power
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
accuracy_decimals: 3
filters:
- multiply: 0.001
time:
- platform: homeassistant
id: homeassistant_time
The multiplication by 0.001 is required when the source power is in watts and you want the integrated result expressed in kWh.
ESPHome enables restoration for this helper by default, so an ordinary device reboot does not automatically throw away the day’s accumulated value. The Home Assistant time source provides the day boundary for the midnight reset.
For the Energy Dashboard, Lifetime Totals Are Usually Cleaner
You do not need a sensor that resets every midnight just because the Home Assistant Energy dashboard shows daily bars. Home Assistant builds daily, weekly and monthly energy statistics from the long-term accumulated sensor.
A lifetime total has several advantages:
- No dependency on ESPHome midnight timing for the main total.
- Easy comparison with a physical electricity meter.
- Home Assistant can calculate any reporting period from the same source.
- Fewer resets and discontinuities to troubleshoot.
Daily sensors are still useful for local displays or device-side logic, but for grid import or total device consumption, a reliable cumulative meter is normally the strongest Energy-dashboard source.
Pulse Meter Example That Works with Energy
If your electricity meter generates 1000 pulses per kWh, expose both live watts and cumulative kWh:
sensor:
- platform: pulse_meter
pin: GPIO27
name: "Grid Power"
id: grid_power
unit_of_measurement: "W"
device_class: power
state_class: measurement
internal_filter: 20ms
filters:
- multiply: 60
total:
name: "Grid Energy"
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
accuracy_decimals: 3
filters:
- multiply: 0.001
The Grid Energy entity is the natural source for grid consumption in the Energy dashboard. Grid Power is useful for live charts and current-power displays.
For the component choice and pulse maths, see our ESPHome pulse_meter vs pulse_counter for Utility Meters.
Why the Sensor Still Does Not Appear
If the entity attributes look correct but it is still missing from the Energy configuration, check Home Assistant’s long-term statistics.
Current Home Assistant documentation directs you to the Statistics troubleshooting screen. A sensor with a metadata conflict can be excluded from the Energy selector even though its current state looks perfect.
A classic sequence is:
Day 1:
sensor.my_meter
unit = W
Day 2:
YAML changed
sensor.my_meter
unit = kWh
device_class = energy
state_class = total_increasing
The live entity now says kWh, but the statistics database remembers historical metadata from when it was a watt sensor. Home Assistant detects the incompatible unit history and flags the statistic.
Check the Entity Attributes First
Open the entity in Home Assistant’s developer/state tools and confirm exactly what Home Assistant sees, not what you think the ESPHome YAML should be producing.
For accumulated electricity energy, expect something similar to:
state: 1243.827
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
For live power:
state: 738
unit_of_measurement: W
device_class: power
state_class: measurement
If any one of these attributes is wrong, fix the ESPHome sensor definition before trying to repair statistics.
Then Check Statistics
Open Home Assistant’s Statistics troubleshooting screen and find the entity. If Home Assistant reports a unit or metadata problem, use the offered repair action after confirming which unit is correct.
This is particularly common after changing:
WtokW.WhtokWh.- A generic sensor into
device_class: energy. - The entity’s unit capitalization.
- An old incorrectly configured template sensor into a valid Energy sensor.
Do not edit the Home Assistant database manually as a first step. The Statistics repair UI exists specifically to resolve supported metadata issues safely.
Long-Term Statistics Explained
Home Assistant records short-term statistics every five minutes and builds hourly long-term statistics from them. Current documentation states that long-term statistics are retained rather than being purged with ordinary state history.
The type of statistics depends on state_class:
| State class | Statistics Home Assistant tracks |
|---|---|
measurement | Mean, minimum and maximum |
total | Accumulated state/sum behaviour |
total_increasing | Accumulated growth with reset detection |
This is why simply setting a unit is not enough. The state class tells Home Assistant how the number behaves mathematically.
What Happens When total_increasing Drops?
Home Assistant interprets a decrease in a total_increasing sensor as a new meter cycle or reset. That is useful for counters that reset to zero.
It can also hide a design problem. Suppose your ESPHome pulse total normally reads 425.6 kWh, then an ESP32 reboot causes it to restart at 0.0 kWh. Home Assistant can treat the drop as a reset and continue statistics, but the ESP32 entity no longer matches the physical utility meter.
For pulse-based metering, use a restoration or re-seeding strategy if you need the ESPHome total itself to remain aligned with the physical meter. The Energy dashboard cannot reconstruct pulses that the ESP32 failed to count while it was offline.
Energy Spikes After a Reboot
A huge daily energy spike after an ESP32 or Home Assistant restart usually means the cumulative sensor briefly published an invalid value.
Examples include:
- The meter reports 0 before its real total is restored.
- A Modbus register is temporarily decoded with the wrong byte order.
- A template publishes
NaNor an unrealistic value during startup. - A conversion multiplier changes by 1000×.
- The same entity changes between Wh and kWh without correct metadata repair.
Fix the source first. Repeatedly repairing dashboard history while leaving a bad startup value in ESPHome only guarantees the problem will return.
W vs kW and Wh vs kWh
Use these conversions consistently:
1000 W = 1 kW
1000 Wh = 1 kWh
Power and energy conversions are independent. If a meter gives 12,345 Wh, convert it to:
12345 Wh × 0.001 = 12.345 kWh
If a sensor gives 750 W, multiplying by 0.001 only converts it to 0.750 kW. It does not create an energy total.
A Correct PZEM-Style Setup
A power/energy meter such as PZEM typically exposes both values separately:
sensor:
- platform: pzemac
voltage:
name: "Voltage"
current:
name: "Current"
power:
name: "Power"
device_class: power
state_class: measurement
unit_of_measurement: "W"
energy:
name: "Energy"
device_class: energy
state_class: total_increasing
unit_of_measurement: "Wh"
Use the energy entity for the Energy dashboard. The watts sensor is useful for current-load graphs and power cards.
See our ESP32 PZEM-004T Energy Monitor guide for the complete implementation.
A Correct Modbus Energy Meter Setup
For an SDM120, SDM630 or similar Modbus meter, use the meter’s true cumulative import-energy register where possible rather than integrating instantaneous watts yourself.
A correctly decoded total should be presented as:
unit_of_measurement: "kWh"
device_class: energy
state_class: total
If that physical register never resets during normal operation, total is a clean semantic match. total_increasing is also accepted by the Energy dashboard and is commonly used when the source can reset.
Do not use a signed instantaneous active-power register as though it were lifetime energy. A value that moves positive and negative is power flow, not an accumulated consumption counter.
Grid Import, Grid Export and Solar
The Energy dashboard works best when import and export are separate cumulative energy entities.
| Quantity | Preferred sensor behaviour |
|---|---|
| Grid import | Ever-growing imported kWh total |
| Grid export | Ever-growing exported kWh total |
| Solar generation | Ever-growing generated kWh total |
| Battery charge energy | Accumulated charged energy |
| Battery discharge energy | Accumulated discharged energy |
A single instantaneous signed power sensor is useful for real-time flow but cannot replace all of those cumulative energy totals.
Sensor Appears in States but Not Energy
Use this order:
- Confirm it is a
sensor.*entity. - Check
unit_of_measurement. - Check
device_class. - Check
state_class. - Confirm the numerical value represents the claimed physical quantity.
- Open the Statistics troubleshooting page.
- Repair any unit/statistics metadata issue.
- Return to the Energy dashboard configuration and look for the sensor again.
If these are all correct, restarting the ESPHome device is rarely the answer. The Energy selector depends on Home Assistant entity/statistics metadata, not on repeatedly rebooting the ESP32.
Do Not Delete the Entity Just to Make It Reappear
Renaming or deleting an entity can appear to fix a statistics problem because Home Assistant treats the new statistic ID as a fresh source. The cost is fragmentation of your historical data.
If the problem is only an old unit mismatch, use Home Assistant’s Statistics repair flow first. Preserve the existing entity ID when possible if long-term history matters.
Changing an Entity ID Does Not Magically Move Statistics
Long-term statistics are keyed to a statistic ID. If you radically rename or replace an energy entity, verify what happened to the old history rather than assuming Home Assistant automatically merged everything.
For a production energy monitor, choose sensible entity names before accumulating months of data:
sensor.grid_import_energy
sensor.grid_export_energy
sensor.solar_generation_energy
sensor.house_power
Clear semantics make future troubleshooting much easier than generic names such as sensor.energy_1.
Should ESPHome or Home Assistant Calculate Energy?
| Method | Advantages | Disadvantages |
|---|---|---|
| Physical meter cumulative register | Best source; survives controller outages | Requires meter that exposes total energy |
| ESPHome pulse total | Directly tied to meter pulses | Needs deliberate restoration/re-seeding strategy |
| ESPHome integration sensor | Continues while Home Assistant is unavailable | Accuracy depends on power sample quality |
| Home Assistant Integral helper | Easy to configure and adjust centrally | Depends on received power history |
My preference is: use a real cumulative meter register first, pulse totals second, and mathematical integration of watts when no direct energy total exists.
Why Home Assistant Energy Can Differ from the Physical Meter
Small differences can occur for several reasons:
- Power integration is based on discrete samples rather than a physical revenue meter.
- ESPHome or Home Assistant was offline and missed samples or pulses.
- A CT clamp has calibration error.
- A pulse reader generated false or missed pulses.
- A Modbus conversion factor or register type is wrong.
- Grid import/export is being derived incorrectly from signed power.
For billing comparison, the utility meter remains the reference. Home Assistant is excellent for monitoring and analysis, but a DIY CT or pulse interface should be calibrated and sanity-checked against the physical meter.
Common Error: Multiplying by 0.001 Twice
This is especially easy with ESPHome total_daily_energy and integration sensors.
If your source is in watts and the integration returns watt-hours, multiplying by 0.001 gives kWh. But if the source has already been converted to kW and the integration is configured in hours, another 0.001 can make the value one thousand times too small.
Work through the units explicitly:
W × hours = Wh
kW × hours = kWh
Wh × 0.001 = kWh
If the dashboard says your entire house used 0.008 kWh yesterday, the problem is probably arithmetic rather than exceptional efficiency.
Common Error: Using Daily Energy as a Power Sensor
A daily kWh sensor is an accumulated quantity. It should not be:
device_class: power
state_class: measurement
It should use an energy device class and total-style state class. Conversely, a live W sensor should not use device_class: energy.
Common Error: Publishing unavailable as Zero
If an energy meter becomes temporarily unavailable, publishing 0 is not always equivalent to saying “no data”. For a cumulative total, a sudden zero can look like a meter reset.
Where possible, let an unavailable sensor remain unavailable until a valid cumulative reading returns. Do not use filters that replace every missing value with zero unless zero genuinely represents the physical measurement.
Home Assistant Individual Devices Can Use Power Sensors Too
Current Home Assistant energy documentation also supports appropriate power sensors for individual-device monitoring. A valid power sensor uses device_class: power, state_class: measurement and a compatible unit such as W or kW.
For the most robust energy history, however, an actual energy total remains preferable when the device provides one. If a smart plug exposes both W and kWh, use the kWh sensor for accumulated energy and W for live power.
Troubleshooting Table
| Symptom | Likely cause | Fix |
|---|---|---|
| Sensor missing from Energy selector | Wrong metadata or statistics error | Check attributes, then Statistics |
| Watts sensor shown as energy | Wrong device class/unit | Use power + measurement, then integrate to energy |
| Energy graph jumps by 1000× | Wh/kWh conversion error | Check every multiplier |
| Huge spike after reboot | Invalid startup/reset value | Fix source restoration/startup publishing |
| Daily sensor starts at zero each midnight | Normal daily reset | Use total_increasing or prefer lifetime total for dashboard source |
| History disappeared after rename | New statistic ID/entity | Preserve entity IDs and repair metadata instead |
| Entity shows kWh but still missing | Old statistics unit conflict | Use Statistics repair action |
| Total falls after ESP32 reboot | Counter not restored | Persist/re-seed or use physical lifetime register |
| Energy slowly differs from utility bill | Integration/calibration/pulse error | Compare against physical meter over several days |
| Power looks correct but energy never increases | No integration/energy source configured | Add ESPHome integration sensor or HA Integral helper |
A Clean ESPHome Energy Pattern
If your hardware only provides power, a good generic ESPHome pattern is:
sensor:
- platform: template
name: "Load Power"
id: load_power
unit_of_measurement: "W"
device_class: power
state_class: measurement
accuracy_decimals: 1
- platform: integration
name: "Load Energy"
sensor: load_power
time_unit: h
restore: true
unit_of_measurement: "Wh"
device_class: energy
state_class: total_increasing
accuracy_decimals: 1
Then use Load Energy in the Energy dashboard and Load Power for real-time dashboards.
Recommended Troubleshooting Order
- Decide whether the source is power or energy.
- Confirm the numerical unit is physically correct.
- Set the correct
device_class. - Set the correct
state_class. - Check the live entity attributes in Home Assistant.
- Open the Statistics troubleshooting screen.
- Repair any old unit/metadata conflict.
- Check the Energy selector again.
- Only then investigate recorder/database issues if the problem remains.
Most missing ESPHome Energy sensors are solved before step eight.
Related ESP32 Energy Guides
- ESPHome pulse_meter vs pulse_counter for Utility Meters — pulse totals, debounce and kWh conversion.
- ESP32 Energy Monitoring Methods Compared — pulse, CT, PZEM and Modbus approaches.
- ESP32 Electricity Meter Pulse Reader for Home Assistant — direct utility-meter pulse monitoring.
- ESP32 CT Clamp Energy Monitor — calibrating current and calculating power/energy.
- ESP32 PZEM-004T Energy Monitor — power plus accumulated energy from a dedicated metering module.
External Resources
- Home Assistant Energy FAQ — current entity requirements and troubleshooting missing sensors.
- Home Assistant Energy management — grid, solar, batteries, gas, water and individual devices.
- Home Assistant long-term statistics — measurement vs total statistics behaviour.
- ESPHome Total Daily Energy — integrating power into daily Wh/kWh.
- ESPHome Integration Sensor — creating lifetime energy from power.