The first thing the Home Assistant Energy dashboard needs is how much electricity you take from the grid, and the most direct place to read that is the meter. Some meters make it easy with a standardized local port, like P1 in the Netherlands, Belgium and Luxembourg. Many others, older ones especially, have no data port at all. What most of them do have is a small LED that flashes as energy passes through.
Put a photodiode over that LED, connect it to an ESP32 running ESPHome, and you get live power in watts and a running total in kWh, read locally, with no cloud service and no wiring work in the electrical cabinet. Below: how to check the meter, what to buy and how to wire it, two ways to install the firmware, the conversion factors, and the faults people run into most.
Check the meter first
Look at the meter's faceplate for a value in imp/kWh, the number of LED flashes per kilowatt-hour. Write it down, because every calculation below depends on it. The Glow documentation mentions 1000 and 2000 as typical values, and Home Assistant uses 1000 in its own example: at that rate each flash means 1/1000 kWh, or 1 Wh.
The ESP32 counts flashes and measures the time between them. From the count you get energy, and from the gap between two flashes you get the current power. That is the whole principle, and it is also why the imp/kWh value has to be right: if it is wrong, every reading is off by the same factor.
It also explains why this method is attractive compared with a CT clamp. A current clamp has to go around a wire inside your electrical cabinet, and Home Assistant's own documentation says that job should be done by someone familiar with electrical wiring and may require a licensed professional in some regions. A photodiode stuck to the outside of the meter does not touch any wiring.
Parts and wiring
Home Assistant Glow is an open source ESPHome firmware built for exactly this job, and the Home Assistant documentation points to it for meters with a pulse LED. Its getting started guide lists the hardware:
- An ESP board. A plain ESP32 is the recommended choice. ESP32-C3 and ESP8266 boards also work.
- An LM393 photodiode module. Be careful when ordering: the Glow docs warn that boards with an LDR (light-dependent resistor) are also sold under similar names. You want the photodiode version.
- Female-to-female jumper wires.
- Optionally, a 5 mm common-cathode RGB LED as a status light. It blinks red on each counted pulse and flashes blue while Wi-Fi is down.
On an ESP32, the wiring from the Glow pinout table is:
| Photodiode module | ESP32 |
|---|---|
| DO | GPIO26 |
| VCC | 3V3 |
| GND | GND |
| A0 | not connected |
For an ESP32-C3 the Glow pinout uses GPIO10 for DO, and for an ESP8266 it uses GPIO13 (labeled D7 on many boards). Board layouts differ, so check the pinout of your exact board before wiring.
Mount the photodiode directly over the meter's pulse LED and keep stray light and reflections away from it. The project provides a 3D-printable case for this, but any enclosure that holds the sensor still and keeps it in the dark will do.
Option 1: install Home Assistant Glow from the browser
If your goal is a working meter reader rather than your own YAML, this is the shortest route.
- Open the getting started page on glow-energy.io in a Chromium-based browser on a desktop computer. The installer does not work on tablets or phones.
- Pick the firmware variant: Standard if you fitted the RGB LED, Basic if you only connected the photodiode.
- Connect the board over USB, select its serial port and install. If the installation fails, hold the boot button on the board and try again.
- Enter your 2.4 GHz Wi-Fi credentials when prompted.
- Add the device to Home Assistant, either through the link the installer offers or by waiting for it to appear as discovered under Settings > Devices & services.
- Set the Pulse rate entity to the imp/kWh value from your meter. The default is 1000.
The default Glow firmware does not use an API encryption key. If Home Assistant asks for one, the Glow FAQ says the device was probably adopted in ESPHome Builder by accident.
Adopting the device in ESPHome Builder ("Take Control") is still the right move if you want to change the configuration. Be aware of what it does: it replaces the default firmware with your own ESPHome configuration, adds an encryption key, uses the Wi-Fi credentials from your ESPHome secrets, and stops automatic firmware updates from glow-energy.io. From then on, updates are your job. You can go back to the stock firmware by reinstalling it over USB, which removes your changes.
Option 2: write the configuration yourself
The Glow firmware is built on ESPHome's pulse_meter sensor, so you can reproduce its core in your own configuration. This example assumes a plain ESP32, the photodiode on GPIO26 and a meter rated at 1000 imp/kWh:
esphome:
name: energy-meter
esp32:
board: esp32dev
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
logger:
api:
encryption:
key: !secret api_encryption_key
ota:
platform: esphome
time:
- platform: homeassistant
id: ha_time
sensor:
- platform: pulse_meter
id: house_power
name: "House power"
pin: GPIO26
unit_of_measurement: W
device_class: power
state_class: measurement
accuracy_decimals: 0
internal_filter: 200ms
filters:
- multiply: 60 # (60 / 1000 imp/kWh) * 1000 W
total:
name: "House energy total"
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
accuracy_decimals: 3
filters:
- multiply: 0.001 # 1 / 1000 imp/kWh
- platform: total_daily_energy
name: "House energy today"
power_id: house_power
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
accuracy_decimals: 3
filters:
- multiply: 0.001 # W to kW
The two multipliers
pulse_meter reports pulses per minute by default. To turn that into watts, multiply by (60 / imp) * 1000. At 1000 imp/kWh that is 60; at 2000 imp/kWh it is 30. ESPHome's documentation shows the same formula for a 10000 imp/kWh meter, where the factor is 6.
The total sub-sensor counts raw pulses. Multiply by 1 / imp to get kWh: 0.001 at 1000 imp/kWh, 0.0005 at 2000.
Units and classes matter here. Home Assistant only offers a sensor for the grid section of the Energy dashboard if it has device_class: energy and a state_class of total or total_increasing, plus a supported unit such as kWh. Power sensors need device_class: power with state_class: measurement.
The internal filter
internal_filter throws away pulses that arrive too close together. In the default EDGE mode, ESPHome compares consecutive rising edges and discards the later one if the gap is shorter than the filter. The ESPHome docs size it from the highest load you expect: at 16 kW and 10000 imp/kWh no real pulse can come sooner than 22.5 ms, so they set the filter about 10 percent lower, at 20 ms.
You can do the same calculation for your meter. The shortest possible gap in seconds is 3600 / (imp/kWh * maximum load in kW). For 1000 imp/kWh and the same 16 kW, that gives 225 ms, so 200 ms in the example above. Recalculate with your own rate and the real maximum of your connection; if the filter is longer than the gap between real pulses, you will undercount at high load.
Home Assistant Glow takes a different starting point. It sets 1000 µs (1 ms) by default and exposes the value as an Internal Filter entity you can change from Home Assistant, and its docs call 1 to 10 ms a good starting point for most homes. In the Glow firmware that entity overrides any internal_filter in YAML after boot.
Daily energy and the time source
total_daily_energy integrates the power sensor and resets at midnight, so it needs a time component. The homeassistant platform takes the time from Home Assistant over the API. If your daily value never resets, the Glow FAQ suggests switching to platform: sntp.
You do not need both energy sensors in the Energy dashboard. The Glow documentation says either the daily or the total sensor works, and that a reset during the day, for example after an update or a reboot, is handled by Home Assistant's long-term statistics.
Add it to the Energy dashboard
- Go to Settings > Dashboards > Energy.
- Under Electricity grid, add a grid connection.
- Select the energy sensor as the energy consumed from the grid.
- Optionally add the power sensor as well, and a price if you want cost tracking.
- Save.
Do not expect graphs straight away. The Glow docs say a newly added device can take up to two hours before enough long-term statistics exist to show up in the dashboard.
If the sensor is missing from the list, the Home Assistant energy FAQ points to three checks: the attributes above (look in Settings > Tools > States), the entity being a sensor and not something like an input_number, and no open issues for it under Settings > Tools > Statistics. The grid documentation adds one more: the sensor must be recorded by the Recorder.
If you pay a day/night or other time-based tariff, the meter LED does not tell Home Assistant which tariff applies. The energy FAQ recommends the utility_meter integration with one tariff per price period. Add each resulting sensor to the dashboard separately. Summing several resetting sensors into one template or group sensor can produce inflated totals, because they never reset at exactly the same moment and the false intermediate value lands in long-term statistics.
Cut down the number of updates
With 1000 imp/kWh, a load of 3600 W produces one pulse per second. The Glow FAQ counts two state changes per second in Home Assistant at that load, 7200 an hour. If you do not need that resolution, ESPHome filters can thin it out. This is the Glow recipe, written for the IDs in the example above:
sensor:
- platform: pulse_meter
# ...
filters:
- multiply: 60
- throttle_average: 10s
- filter_out: NaN
total:
# ...
filters:
- multiply: 0.001
- delta: 0.01
- heartbeat: 300s
The power sensor now reports a 10-second average, and the total updates after a change of at least 0.01 kWh or every five minutes, whichever comes first. According to the Glow FAQ, this brings it down to 396 state changes per hour. If you use the Glow firmware itself, use !extend sensor_energy_pulse_meter as shown on that FAQ page instead of rewriting the sensor.
Make the total match the meter
pulse_meter can set its pulse count to any value with the pulse_meter.set_total_pulses action. Expose it as an API action and you can align the ESP32 total with the reading on the meter display:
api:
encryption:
key: !secret api_encryption_key
actions:
- action: set_total
variables:
new_total: int
then:
- pulse_meter.set_total_pulses:
id: house_power
value: !lambda 'return new_total;'
The value is a raw pulse count, not kWh, because the action works on the count before any filters are applied. At 1000 imp/kWh, a meter reading of 12345 kWh means 12345000 pulses. The Glow firmware does this multiplication for you: it has a Reset Value - Total Energy kWh number entity and a Reset - Total Energy button that sets the count to that value times the pulse rate.
Skipping this step does not hurt the Energy dashboard. Long-term statistics follow how much the total grows, which is also why the Glow docs say a reset does not break anything. Matching the meter mostly means seeing the same number in both places.
Common problems
- No pulses at all. Check the alignment over the LED, the light shielding and the sensitivity setting on the module. The Glow FAQ also documents photodiodes delivered soldered the wrong way round: the larger triangular part of the diode should go to the positive side of the board. If it is reversed, the LED will not be detected whatever the sensitivity.
- Absurd spikes, like 1000 kW. These are ghost pulses from electrical noise or reflections near the LED. Increase the internal filter step by step. Going too far will drop real pulses at high load.
- A sudden jump in daily energy after a long period of zero, with solar. The Glow FAQ suggests
method: lefton thetotal_daily_energysensor instead of the defaultright. - Daily energy does not reset at midnight. Switch the time source to SNTP.
- Readings consistently too high or too low. Recheck the imp/kWh value and both multipliers.