I collect pulse from several sources (Kwh pulse counters and watermeter)
See below image, channel 0-4 are the pulses counted every 10 seconds for 5 different sources and channel 5-9 are the total pulses counted for the same fie sources.
I think you mean: 1 kWh = 10.000 pulses?
So 1 pulse = 0.0001 kWh.
And you can turn you pulse-counter into a kWh-counter by doing: kWh-count = pulse-count x 0.0001
Use a template sensor for that.
If you want that, you can use this: https://www.home-assistant.io/integrations/derivative/
That will give you “change in pulses per time-unit” and you will need to translate this to for instance W: W = kWh/(1000*time-unit in hours).
time-unit in hours means: time-unit of 10s = (1/360) hour
For the third and final time, look at the change_rate attribute of the statistics sensor, that is your “instantaneous power”. You can display the attribute directly in Lovelace or use a template sensor to break it out from the statistics sensor.
Or as Bouwe pointed out use the derivative sensor that (sorry) does actually exist.
Sorry for my ignorance, but I’m still confused.
As stated in my first post, I want to calculate the current (realtime) usage in Watts (not KwH’s)
I have 2 types of sensors; pulses per 10 seconds and tot pulses. The update time for both is 10 seconds.
For starters; which of the 2 type do I have to use for this ?
See the screenshot of what I see now.
OK, But I can’t find any good documentation of the change_rate attribute, so please just tell me how to use it. same goes for the derivative sensor. I am using it, but it does not give the desired results.
I just need some more help than just tell me to use it, I like to know how to use it.
I think what RienduPre is missing is that HA internally keeps track of the time when the pulses occur, so the derivative sensor (what delivers the same info as the change_rate attribute of the statistics sensor, as mentioned above), can show number of pulses/time. Multiply with 10000 (or divide, I’m not paying attention here), and you should have Wh*time, which is power (W).
Only caveat: does HA keep track of time in ms, and what is the jitter (lack of real-time) of your signal path?
Which hardware is doing the counting, and how did you interface it to your HA hardware?
To be able to turn pulses in to Watt, you need to define your measurement interval, say 10 second.
Then you need to count pulses per 10 seconds.
10000 pulses = 1 kWh --> 10 pulses = 1 Wh --> 1 pulse = 0.1 Wh
Suppose you measure 8 pulses in 10 secs, that translates to:
8 * 0.1 = 0.8 Wh
Now divide by time: the 10 secs interval:
0.8 * 360 (10 second = (1/360)h) = 288W.
So the formula is: sensor-value * 0.1 * (time-interval in secs/3600)
The derivative-sensor should give you the amount of pulses per time-interval.
You can use a 2nd template-sensor to translate the sensor-value to Watt.
See here: https://www.home-assistant.io/integrations/template/
Scroll down to the example called CHANGE THE UNIT OF MEASUREMENT.
I’ve been trying out many settings to get an accurate reading which updates near realtime.
I use the statistics sensor’s change_rate and a template sensor. see below:
So I’m nearly happy with the result except for the rounding of the value.
See example below
I used "round(0) in the template definition, but this does not work. Is this a bug or am I doing something wrong?