Detect small leak from liters/min sensor

Hi

I’m using a Connectix gateway to monitor my home water counter. I created a liters/minute sensor using the derivative platform. So far so good.

I do have some node-red flow to trigger if the liters/minute sensor stays above 0 for some period of time (10 minutes for instance), but I had a situation the other day I don’t know how to properly handle to be able to detect it and create a relevant alarm. As you can see from the picture below, this sensor was constantly fluctuating between 0 and about 1 Liter/min (red boxes).

The other peaks were basically normal usage of water. It turns out the toilet flush remained a bit stuck, and water was dripping. So not strong enough for the liters/minute to constantly remain bigger than 0, just small enough to have the sensor fluctuate constantly between 0 and 1,x liters/minute.

How is it possible to detect such fluctuation, ie. how would you implement this in Node Red ? Ideally I’d like to determine a time window (60 minutes for instance) and set some threshold for fluctuation (like if this sensors goes at least 15 times between 0 and >0 within 60 minutes, send a notification for potential leak).

Any idea or suggestion ?

You could monitor for non-zero usage over (say) 5 minute blocks and if you never had a single non-zero 5-minute block over the last 5 5-minute blocks then flag that as a leak. Obviously if someone is taking a long >25 minute shower you will have false triggers.
I have done something similar with node red but not this exact logic but it should be fairly straightforward.

Not sure this is going to work, as in case of small leaks the liters/min sensor would not stay > 0 for minutes. If I zoom a bit on the situation I showed in my first post, this is what I get:

You see that for instance between 13:25 and 13:30, this sensor never stayed > 0 for even 1 minute.

Here is another leak example, where the water supply had not been cut off on the garden hoses, and although closed the hoses was leaking slightly:

Here too, checking of the sensor remains > 0 for 5 minutes would not help as the fluctuations appear more frequently

I think what @zraken suggested was to watch out for 5 min blocks with absolut no flow. if you dont have 5 mins with absolut zero flow in say an hour period, you know you are likely to have a dripping thing somewhere.

This has been on my too long todo list for a while now and unfortunately have yet to get to it. Maybe you have some time to experiment…Their benchmarks are on some impressive compute platforms, so maybe this would not even work on a small cpu, but have a look. The idea that I think you can do with this package is to capture a ‘pattern’ time sequence and then have package find that in a time series stream… good hunting!

STUMPY is a powerful and scalable library that efficiently computes something called the matrix profile, which can be used for a variety of time series data mining tasks such as:

  • streaming (on-line) data

Fast Pattern Matching
https://stumpy.readthedocs.io/en/latest/Tutorial_Pattern_Matching.html

https://stumpy.readthedocs.io/en/latest/index.html

Use a low pass filter to smooth out your data. Then use a numeric state trigger if the level is above x for 5 or 10 minutes.

Thanks. STUMPY looks a bit overkill to me. Filter is an interesting track, but I really wonder how to leverage Node Red to do this. I should maybe take a look at the Smooth node, which seems to allow for low pass filtering.
I also wonder if another approach could be to create another derivative sensor. My current L/min sensor is based on the derivative platform, taking a time period of 60s. Maybe having a new derivative sensor with a larger time window (5 minutes for instance) could help catch those fluctuating situations.

Ha filter creates a new entity, and that could be used as a trigger in node red. If you want to do this all in node red use an event state to get the raw feed for the sensor.

Send that through a switch and count how many times you get a reading between 0-1. If it counts more than say 10 values it will send a message and reset the counter. If there is a peak > 1 it resets the counter as well.

[{"id":"dca65fd242b73688","type":"server-state-changed","z":"f80b6c338afd5483","name":"","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.water_meter","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":880,"y":2320,"wires":[["2e52deecc63c3e7b"]]},{"id":"2e52deecc63c3e7b","type":"switch","z":"f80b6c338afd5483","name":"","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":".1","vt":"num","v2":"1","v2t":"num"},{"t":"gt","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":1110,"y":2320,"wires":[["8641f324bcc4fba3"],["c29851c26f644d86"]]},{"id":"8641f324bcc4fba3","type":"counter","z":"f80b6c338afd5483","name":"","init":"0","step":"1","lower":"","upper":"10","mode":"increment","outputs":"1","x":1480,"y":2320,"wires":[["426c74b1577b9033"]]},{"id":"c29851c26f644d86","type":"change","z":"f80b6c338afd5483","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":2380,"wires":[["8641f324bcc4fba3"]]},{"id":"426c74b1577b9033","type":"switch","z":"f80b6c338afd5483","name":"","property":"count","propertyType":"msg","rules":[{"t":"eq","v":"10","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1650,"y":2320,"wires":[["c29851c26f644d86","6634c1a0744974c7"]]},{"id":"6634c1a0744974c7","type":"api-call-service","z":"f80b6c338afd5483","name":"notify","server":"","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1850,"y":2320,"wires":[[]]}]

Thanks, I’ll definitely try this one!
Just wondering if I could also inject some time dimension in this flow, like the counter should reach 10 to trigger a notification only if these 10 counts happened within xx minutes max.

I don’t think it is necessary as every time the water is legitimately used it resets. If there are long periods of in activity, you could use an inject node to send a message at a specific time or interval daily. Or a stop timer for a max time between events.

[{"id":"dca65fd242b73688","type":"server-state-changed","z":"f80b6c338afd5483","name":"","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.water_meter","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":760,"y":2320,"wires":[["2e52deecc63c3e7b"]]},{"id":"2e52deecc63c3e7b","type":"switch","z":"f80b6c338afd5483","name":"","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":".1","vt":"num","v2":"1","v2t":"num"},{"t":"gt","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":990,"y":2320,"wires":[["8641f324bcc4fba3","3fb992490df612a6"],["c29851c26f644d86"]]},{"id":"8641f324bcc4fba3","type":"counter","z":"f80b6c338afd5483","name":"","init":"0","step":"1","lower":"","upper":"10","mode":"increment","outputs":"1","x":1480,"y":2320,"wires":[["426c74b1577b9033"]]},{"id":"c29851c26f644d86","type":"change","z":"f80b6c338afd5483","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":2380,"wires":[["8641f324bcc4fba3"]]},{"id":"426c74b1577b9033","type":"switch","z":"f80b6c338afd5483","name":"","property":"count","propertyType":"msg","rules":[{"t":"eq","v":"10","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1650,"y":2320,"wires":[["c29851c26f644d86","6634c1a0744974c7"]]},{"id":"6634c1a0744974c7","type":"api-call-service","z":"f80b6c338afd5483","name":"notify","server":"","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1850,"y":2320,"wires":[[]]},{"id":"e3e6a3d38cafb683","type":"inject","z":"f80b6c338afd5483","name":"set daily/interval reset","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":940,"y":2380,"wires":[["c29851c26f644d86"]]},{"id":"3fb992490df612a6","type":"stoptimer","z":"f80b6c338afd5483","duration":"5","units":"Second","payloadtype":"num","payloadval":"0","name":"set max time between events","x":1220,"y":2260,"wires":[["c29851c26f644d86"],[]]}]

How can i make a liter/ per minute sensor?

I usd a helper in homeassistant and works.
Butt when i close the water the liter per minute stays on that rate and not go to zero

I’m using a derivative sensor:

  - platform: derivative
    source: sensor.connectix_watermeter_total
    name: "liters per minute"
    unit_time: min
    round: 1
    time_window: "00:01:00"

where sensor.connectix_watermeter_total is a always increasing sensor with the total liters consumption

Thanks,

I’m gonna try

It worked with youre soluttion.
But only one thing.

It stays in tha last volume and not go to 0 when water is closed.

Is it possible to go to 0 when there is no count?

That’s strange. Mine goes back to zero after water is turned off. It can take a minute or two seen it’s derivative, but it definitely goes back to zero.