Hi, I spent a lot of time playing around with my electricity meter in ESPhome over a year ago and eventually settled on the implementation detailed below which you may be able to adapt for your use case. The two things which I did which resulted in a solid and relabile solution that never seems to reset is the following:
-
Use the total_daily_energy platform is ESPhome (I originally tried the integration platform but had problems with it spiking to an infinite value every couple of months - I was never able to solve this).
-
Use the total_daily_energy sensor as the source for utility_meter sensors in HA (note even though the total_daily_energy sensor from ESPhome resets daily, the utility_meter keeps counting up, I don’t know why but it seems to work well).
ESP Home Config:
sensor:
- platform: pulse_counter
name: 'Meter Power'
id: meter_power
pin: GPIO4
unit_of_measurement: 'kW'
accuracy_decimals: 3
filters:
- multiply: 0.06
- platform: total_daily_energy
name: "Total Daily Energy"
accuracy_decimals: 1
power_id: meter_power
Home Assisistant config:
utility_meter:
energy_usage_hour:
source: sensor.total_daily_energy
cycle: hourly
tariffs:
- std
energy_usage_day:
source: sensor.total_daily_energy
cycle: daily
tariffs:
- std
energy_usage_month:
source: sensor.total_daily_energy
cycle: monthly
tariffs:
- std
You probably do not need my 0.06 multiply filter as these needed to convert 1000 pulses to a kWh.