I have a z-wave water valve that reports instant water flow rate in the units of L/h (liters per hour). The sensor updates everytime the flow rate changes and when no water is running, it is 0 L/h.
I would like to calculate total consumption from this sensor, i.e. total liters or m3 etc.
For example:
V = dt x Q
V = Volume (L)
dt = delta time (h)
Q = Volume flow rate (L/h)
V = dt x Q
assume the water is running for 3 L/h for 0.1 hrs, then:
t = 0.1 hr
Q = 3 L/h
so you get V = 0.3 L total consumed
Riemann sum does not remove the time unit.
The issue im facing is the dt aspect, how do I capture the time now to time when the rate changed?
Here’s an example how the history for the rate sensor, every line represents a time when water was used.
Interesting, I was using the UI to create the sensor.
The docs say this, however:
The unit of source together with unit_prefix and unit_time is used to generate a unit for the integral product (e.g. a source in W with prefix k and time h would result in kWh )
The Riemann Sum approximates the area under the graph. So y * x (for a square graph, an oversimplification).
You have L/h so h will be used from the source sensor:
L/h * h = L (the h’s cancel).
kW * h = kWh (no cancelling).
Don’t specify a unit time (it will be taken from the source sensor) and don’t specify a prefix, unless you want kL in the output sensor. Do specify method: left as you have very spikey data.
Eh, it’s not important as long as you get it right (h). I did not realise it was required in the GUI. However there are other advantages to using YAML. It is a lot easier to reconfigure the sensor if you need to. I’ve seen issues with doing that using the UI. Same goes for the Utility meter.