Stable waterflow detection to detect a leak
Moderator: leecollings
-
- Posts: 108
- Joined: Tuesday 06 February 2018 18:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta rel
- Contact:
Stable waterflow detection to detect a leak
Hello,
I installed a sensor on my water meter, I can then detect water consumption and flow.
When a stable positive flow is detected, this is really suspicious and looks like a water leak.
How is it possible to code with DzVents something like if the waterflow is stable and not equal to zero for more than x min?
I can't find out how to use maybe lastupdate() or any other solution.
Thanks
I installed a sensor on my water meter, I can then detect water consumption and flow.
When a stable positive flow is detected, this is really suspicious and looks like a water leak.
How is it possible to code with DzVents something like if the waterflow is stable and not equal to zero for more than x min?
I can't find out how to use maybe lastupdate() or any other solution.
Thanks
-
- Posts: 504
- Joined: Sunday 01 November 2015 22:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Twente
- Contact:
Re: Stable waterflow detection to detect a leak
Your water meter has a counter?
Just read the log.
No dzvents needed.
Just read the log.
No dzvents needed.
Bugs bug me.
-
- Posts: 108
- Joined: Tuesday 06 February 2018 18:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta rel
- Contact:
Re: Stable waterflow detection to detect a leak
The metering is issued from an ECO-Devices, screenshot below.
-
- Posts: 536
- Joined: Monday 20 March 2023 14:41
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Somewhere in NL
- Contact:
Re: Stable waterflow detection to detect a leak
You could put every minute the waterflow value in a data set like:
then when the max is reached you could compare the last value with the average.
If the difference between those 2 value is less then x you have a constant flow and could act on it.
Make of course an exception for zero.
You should take into account long showers and watering the garden.
See: https://www.domoticz.com/wiki/DzVents:_ ... stent_data
Code: Select all
data = {
waterflow = { history = true, maxItems = 20 }
},
If the difference between those 2 value is less then x you have a constant flow and could act on it.
Make of course an exception for zero.
You should take into account long showers and watering the garden.
See: https://www.domoticz.com/wiki/DzVents:_ ... stent_data
Logic will get you from A to B. Imagination will take you everywhere.
-
- Posts: 108
- Joined: Tuesday 06 February 2018 18:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta rel
- Contact:
Re: Stable waterflow detection to detect a leak
Thanks,Kedi wrote: ↑Sunday 26 May 2024 11:58 You could put every minute the waterflow value in a data set like:then when the max is reached you could compare the last value with the average.Code: Select all
data = { waterflow = { history = true, maxItems = 20 } },
If the difference between those 2 value is less then x you have a constant flow and could act on it.
Make of course an exception for zero.
You should take into account long showers and watering the garden.
See: https://www.domoticz.com/wiki/DzVents:_ ... stent_data
I'll try this
-
- Posts: 108
- Joined: Tuesday 06 February 2018 18:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta rel
- Contact:
Re: Stable waterflow detection to detect a leak
Hello,
No success with history, I then tried avgSince but it is not working either.
Can somebody help me?
Thanks
No success with history, I then tried avgSince but it is not working either.
Code: Select all
2024-05-27 19:20:06.933 Error: dzVents: Error: (3.1.8) water leak: .../pi/domoticz/scripts/dzVents/generated_scripts/Fuite.lua:25: attempt to call a nil value (field 'avgSince')
Thanks
Code: Select all
return
{
on =
{
devices =
{
'Eau-débit',
-- change to name of Sensor
},
},
data =
{
},
logging =
{
level = domoticz.LOG_DEBUG, --LOG_DEBUG, -- change to domoticz.LOG_ERROR when script is tested and OK
marker = 'water leak',
},
execute = function(dz, item)
local avg = dz.devices('Eau-débit').avgSince('00:05:00')
dz.log('\nDevicename: ' .. item.name .. ', nValue: ' .. item.nValue .. ', sValue: ' .. item.sValue ..
'\nDevicetype: ' .. item.deviceType .. ', deviceSubType: ' .. item.deviceSubType )
if (item.nvalue>0) then
dz.log('Mobile average ' .. avg)
dz.log('Flow ' .. item.nValue)
if(item.nvalue==avg) then
domoticz.notify('Water stable flow : ' .. avg .. ' since 5 min')
end
end
end
}
-
- Posts: 536
- Joined: Monday 20 March 2023 14:41
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Somewhere in NL
- Contact:
Re: Stable waterflow detection to detect a leak
Something like this. I did not test it.
Code: Select all
local maxValues = 30 -- number of minutes over which an average is taken
local devWater = 'Water'
local deviation = 0.001 -- deviation from average
-- Don't change anything below this line
return {
active = true,
-- active = false,
on = {
timer = {
'every minute',
},
},
logging = {
-- level = domoticz.LOG_INFO,
level = domoticz.LOG_DEBUG,
marker= 'WFA'
},
data = {
waterflow = { history = true, maxItems = maxValues },
},
execute = function(dz, item)
local _f = dz.data.waterflow -- data set
local nCounter = dz.devices(devWater).counter -- get last watermeter value
local flow = 0 -- initialize flow
if _f.size > 0 then
flow = nCounter - _f.getLatest().data
end
_f.add(nCounter) -- add counter to data set
dz.log('Counter: '..nCounter..' Flow: '..dz.utils.round(flow,3)..' - Avg: '..dz.utils.round(_f.avg(),3)..' Set: '.._f.size, dz.LOG_DEBUG)
-- only after full data set
if _f.size == maxValues then
-- only if there is flow and less then average +/- deviation
if flow > 0 and (nCounter - deviation < _f.avg() and nCounter + deviation > _f.avg()) then
dz.notify('Waterlekkage!', 'Er is waterlekkage in de leiding!!', dz.PRIORITY_EMERGENCY, dz.SOUND_SIR$
end
end
end
}
Logic will get you from A to B. Imagination will take you everywhere.
-
- Posts: 108
- Joined: Tuesday 06 February 2018 18:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta rel
- Contact:
Re: Stable waterflow detection to detect a leak
Thanks,
I did change the dz.devices name but got the following error:
2024-05-29 18:17:00.294 Error: dzVents: Error: (3.1.8) WFA: Item data is not a number type. Type is nil
2024-05-29 18:17:00.294 Error: dzVents: Error: (3.1.8) WFA: An error occurred when calling event handler leak
2024-05-29 18:17:00.294 Error: dzVents: Error: (3.1.8) WFA: /home/pi/domoticz/dzVents/runtime/HistoricalStorage.lua:289: attempt to perform arithmetic on a nil value (local 'sum')
I did change the dz.devices name but got the following error:
2024-05-29 18:17:00.294 Error: dzVents: Error: (3.1.8) WFA: Item data is not a number type. Type is nil
2024-05-29 18:17:00.294 Error: dzVents: Error: (3.1.8) WFA: An error occurred when calling event handler leak
2024-05-29 18:17:00.294 Error: dzVents: Error: (3.1.8) WFA: /home/pi/domoticz/dzVents/runtime/HistoricalStorage.lua:289: attempt to perform arithmetic on a nil value (local 'sum')
-
- Posts: 536
- Joined: Monday 20 March 2023 14:41
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Somewhere in NL
- Contact:
Re: Stable waterflow detection to detect a leak
This script expects a number from "dz.devices(devWater).counter"
Perhaps you have to change the counter with what your device has in its output.
Perhaps you have to change the counter with what your device has in its output.
Logic will get you from A to B. Imagination will take you everywhere.
Who is online
Users browsing this forum: Bing [Bot], heggink and 1 guest