Calculate consumption from a rate sensor (water)

Hi all,

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.

image

Integrating L/h with respect to time using the Riemann Sum sensor will give you total consumption in L.

kW → kWh
Km/h → Km
m/s2 → m/s
L/h → L

If you are not seeing this then you have done something incorrectly. Please share your Riemann Sum config.

Make sure to use method: left to reduce errors in that spikey data.

You can then feed this sensor to utility meter helpers for hourly/daily/monthly/etc… totals if you wish to.

Thanks @tom_l

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 )

Maybe I’m reading something else?

The docs are correct.

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.

1 Like

Perfect this is exactly what I need.

OK, I’ll have to do a yaml configuration because the UI forces me to specify a unit time.

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.

awesome! Ok, have this and will give it a go on next restart

#Water Consumption SMW
- platform: integration
  unique_id: u18adb9dc-1405-4a89-a473-15c18b7adcf3
  source: sensor.smart_water_valve_meter_water_flow
  name: water_consumption_swm
  round: 2
  method: left
1 Like