I have an meter for a heat pump and would like to show the consumption in the energy dashboard the consumption. For this I use the S0 interface as described here
The meter delivers 100 pulses per kwh
Pulse Counter:
sensor:
- platform: pulse_counter
pin: GPIO5
name: 'Power'
id: power
unit_of_measurement: 'kW'
state_class: measurement
device_class: power
filters:
- multiply: 0.6 # (60s/100 pulses per kWh)
total:
name: 'Energy'
id: energy
unit_of_measurement: 'kWh'
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
- multiply: 0.001
Now I saw that there is also a pulse meter sensor. The setup should be similar, correct?
Pulse Meter:
sensor:
- platform: pulse_meter
pin: GPIO5
name: 'Power'
id: power
unit_of_measurement: 'kW'
state_class: measurement
device_class: power
filters:
- multiply: 0.6 # (60s/100 pulses per kWh)
total:
name: 'Energy'
id: energy
unit_of_measurement: 'kWh'
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
- multiply: 0.001
Which platform is better to display the consumption in the Energy Dashboard?
Is there a way to synchronize the kwh on the display with the pulse counter/meter?
I think this is service: Pulse Counter Sensor — ESPHome
If the display show 9000 kwh, i have to put 9000 or 9000 * 100?
“This value is the raw count of pulses, and not the value you see after the filters are applied.”
From this note. I would expect 9000 * 100
As I understand it, the pulse_counter and pulse_meter are similar, but not the same. In this post the differences are nicely explained.
Also, the pulse_counter has more options to tweak the set-up, like count_mode and use_pcnt for ESP32 hardware support.
I am using the pulse_counter for my water meter sensor.
Some small remarks to you code:
filters:
- multiply: 0.6 # (60s/100 pulses per kWh)
The value 0.6 is correct, but the remark should be something like:
filters:
- multiply: 0.6 # (60 minutes per hour / 100 pulses per kWh)
I think this is also wrong on the ESPHome Pulse Counter Documentation page.
pulse_counter is better for dashboard, because it gives you the correct energy.
This is not the case for pulse_meter as this one assumes further energy consumption after turning the device off - for a specified time. And this assumed consumption, which is not real, gives you an error on the energy.
You don’t have this problem witch pulse_counter.
[16:45:50][D][sensor:090]: ‘Power’: Sending state 0.00000 kW with 2 decimals of accuracy
[16:45:50][D][pulse_counter:150]: ‘Power’: Total : 0 pulses
[16:45:50][D][sensor:090]: ‘Energy’: Sending state 0.000 kWh with 3 decimals of accuracy
This is my code:
esp32:
board: esp32doit-devkit-v1
framework:
type: arduino
sensor:
- platform: pulse_counter
pin: GPIO5 #D5
name: 'Power'
id: power
unit_of_measurement: 'kW'
state_class: measurement
device_class: power
filters:
- multiply: 0.6 # (60 minutes per hour / 100 pulses per kWh)
total:
name: 'Energy'
id: energy
unit_of_measurement: 'kWh'
state_class: total_increasing
device_class: energy
accuracy_decimals: 3
filters:
- multiply: 0.01
I tried a new D1 mini board with pin D4 and impulses now seem to be coming in
The values or the conversion into kwh seem to be wrong (around factor 10 to much).
I reset the recorder again and pulse counter again. Then I have tomorrow the right values.
In the meantime maybe a question if I have 100 pulses per kwh.
Aren’t the values 0.6 and 0.01 double converted now? @thusassistint can you explain the value(s)?
Initially I thought that as well: I initially assumed that the total sensor would use the output from the pulse-counter sensor as input.
But that appears not to be the case: the total sensor uses the same input as the pulse_counter sensor, so it counts the raw pulses and not the converted output.
By default the pulse_counter measures the power using pulses/minute.
Your meter gives 100 pulses per kWh.
Let’s assume that the pulse_counter measures 1 pulse / minute.
Then this is 1/100 kWh / minute in your case.
And that is 1/100 * 60 kWh / hour = 0.6 kWh / h = 0.6 kW.
So the multiply factor for the pulse_counter should be 0.6 in your case to measure power in kW with 100 pulses per kWh.
The total sensor by default just counts the total number of accumulated pulses.
So if the total amount of pulses for instance is 10000 this is 10000/100 = 100 kWh in your case.
So you have to use a multiply factor of 0.01 for the total sensor to convert the total number of pulses to kWh in your case.
Ok interesting, but I see my on meter I have 0,2 kwh and the sensor has 2480 kwh. So something went wrong. Let’s try 1000 pulses per kwh. On the meter I see 100 per kwh, but on the documentation it’s 1000 .
Hey,
I didn’t read all responses but as I had a related issue some time ago…
My use case was a bit more complicated and posed a bit of a challenge.
It is my personal believe that the esphome implementations pulse_meter as well as pulse_counter are flawed, i.e. limited in functionality and very badly documented. Someone should unify them into one consistent pulse measurement component.
Anyhow, I ended up building what I needed by myself, which is quite easy. @MelleD maybe consider that:
Works quite well so far and the values are accurate.
However, I still have the problem that as soon as an ESP home update comes in and I install it, the total sensor always jumps to 0 after the update. Can this be prevented?
What I did with my water meter is adding a global variable in which the total value is stored on shutdown and at an interval, and which value is restored at startup.
Something like this:
I don’t think this is such a big issue because ESPHome is only really writing a value to flash when the previous value is indeed changed.
With my method it is still possible to adjust the value via an input option in HA if required.
I do this as well with my water meter to correct for small deviations with the real water meter.
I prefer to keep the sensor output processing local on the ESP as much as possible, so that this is not disturbed by a (short or long) outage of Home Assistant.
So when HA is offline and comes back online again the sensor values from the ESPs are still accurate.
Looks like a bit of a workaround. Pity that there is no out of the box solution. Maybe raise up a feature request or at least a contribution in the documentation.
Does your solution also work with the Energy dashboard?
If I manually after startup set the pulse_counter.set_total_pulses. I have to delete the wrong statistic for the dashboard