Wrong sum when using a Pulse_counter sensor

I have built a water meter sensor with the pulse_counter platform. Everything work fine and the logs show that it reports correctly the number of litres consumed every 60s.
My issues is in HA for whatever methode I do to get a daily sum of the litre comsumed (through the utility_meter integration or mini-graph) I get a wrong total.

After many hours, I can finally pinpoint the issue, and it looks as everytime the value sent by ESPhome is identical to the one sent previously, it is ignore by HA. For exemple, this the pattern I have seen in ESPHome and HA logs:

time stamp ESPhome reports HA assistant have logged
00:00:00 0 0
00:01:00 0
00:02:00 0
00:03:00 2 2
00:04:00 3 3
00:05:00 3
00:06:00 0 0
00:07:00 4 4
00:08:00 4
00:09:00 4
00:10:00 4
00:11:00 0 0
Sum= 24 Liter (correct) Sum = 9 Liter (wrong)

I assumed that any duplicate data are ignored in HA logs to avoid the database to explose in size, but how to calculate a correct sum for exemple using the utility_meter platform or mini-graph? Did I miss something?

Tanks for any help,

Matthieu

The utility meter expects an always increasing value. i.e. total litres of water used, not a flow rate of litres of water used per minute.

You can use the integral sensor to convert your flow rate to total used and feed that to the utility meter.

Wahoo, thanks for a fast explanation/answer :slight_smile: .
I now got smarter today and learned about the integration platformed and Riemann integral.
Thanks, I will look into this path.

1 Like