Currently i'm running an setup with a NPN watermeter sensors and this works fine.
Yesterday the water run for a couple of hours (4 hours) and nobody was at home, so i've lost almost 2000 liter water. I've calculated is should be around 5 liters a minut.
So avoid this (or be notified earlier) i'm looking for a script that could help me but because i don't get DzVents as everyone else (maybe i'm thinking to difficult?) but the idea should be simple:
--- Watermeter IDx 30
return {
on = {
devices = {
'Watermeter'
}
},
execute = function(domoticz, device)
watermeter.Usage = myVar.subsetSince('00:17:00') --- Get data from last 17 minutes
if(watermeter.Usage > 94) then
domoticz.notify('Water usage high!!',
'The waterusage is more than 5,5 liter a minute!',
domoticz.PRIORITY_HIGH)
end
end
}
The idea is very simple, but i'm not getting it working (And i would like to not test it for 17 minutes)
Evertjob89 wrote: ↑Monday 17 December 2018 16:37
So avoid this (or be notified earlier) i'm looking for a script that could help me but because i don't get DzVents as everyone else (maybe i'm thinking to difficult?) but the idea should be simple:
The idea is very simple, but i'm not getting it working (And i would like to not test it for 17 minutes)
Can you tell us what device type and subtype your watermeter in domoticz is ?
Goto the devices tab in the domoticz gui and type water in the search field. I am interested in the idx, name, type and subType values. My screen shows something like:
Evertjob89 wrote: ↑Monday 17 December 2018 16:37
So avoid this (or be notified earlier) i'm looking for a script that could help me but because i don't get DzVents as everyone else (maybe i'm thinking to difficult?) but the idea should be simple:
The idea is very simple, but i'm not getting it working (And i would like to not test it for 17 minutes)
Can you tell us what device type and subtype your watermeter in domoticz is ?
Goto the devices tab in the domoticz gui and type water in the search field. I am interested in the idx, name, type and subType values. My screen shows something like:
Evertjob89 wrote: ↑Monday 17 December 2018 16:37
Currently i'm running an setup with a NPN watermeter sensors and this works fine.
I'm looking for a script that could help me but because i don't get DzVents as everyone else (maybe i'm thinking to difficult?) but the idea should be The idea is very simple, but i'm not getting it working (And i would like to not test it for 17 minutes)
Could be something like this. Please check the log for a couple of hours to see if factor is set right for your meter.
Evertjob89 wrote: ↑Monday 17 December 2018 16:37
Currently i'm running an setup with a NPN watermeter sensors and this works fine.
I'm looking for a script that could help me but because i don't get DzVents as everyone else (maybe i'm thinking to difficult?) but the idea should be The idea is very simple, but i'm not getting it working (And i would like to not test it for 17 minutes)
Could be something like this. Please check the log for a couple of hours to see if factor is set right for your meter.
Evertjob89 wrote: ↑Monday 17 December 2018 16:37
Currently i'm running an setup with a NPN watermeter sensors and this works fine.
I'm looking for a script that could help me but because i don't get DzVents as everyone else (maybe i'm thinking to difficult?) but the idea should be The idea is very simple, but i'm not getting it working (And i would like to not test it for 17 minutes)
Modified the calculation of current flow. Can you try this ? and please check the log for a couple of hours to see if factor is set right for your meter.
return {
on = { devices = { "Watermeter" }},
data = { watermeter = { history = true, maxHours = 2 }},
logging = {
level = domoticz.LOG_DEBUG,
marker = "watermeter"
},
execute = function(dz,item)
local function logWrite(str,level)
dz.log(tostring(str),level or dz.LOG_DEBUG)
end
-- JSON call to emulate waterflow
-- http://192.168.192.51:8084/json.htm?type=command¶m=udevice&idx=1242&svalue=0
dz.data.watermeter.add(item.counter)
local minutes = 17
local maxLitersPerMinute = 5.5
local factor = 100
local max = dz.data.watermeter.maxSince('00:'.. minutes .. ':00')
local min = dz.data.watermeter.minSince('00:'.. minutes .. ':00')
local litersPerMinuteNotify = (max - min) / minutes * factor
local current = dz.data.watermeter.get(1).data
local previous, previousTime, litersPerMinuteNow
if dz.data.watermeter.get(2) ~= nil then
previous = dz.data.watermeter.get(2).data
previousTime = dz.data.watermeter.get(2).time.msAgo
litersPerMinuteNow = (( current - previous ) / (previousTime / 60000 )) * factor -- 60000 = msecs in a minute
logWrite("Current water usage: " .. dz.utils.round(litersPerMinuteNow,1) .. " liter a minute")
else
logWrite("Current water usage cannot be determined (not enough data in history)")
end
if litersPerMinuteNotify > maxLitersPerMinute then
dz.notify (
'Water usage high!!',
'The waterusage is ' .. dz.utils.round(litersPerMinuteNotify,1) .. ' liter a minute!',
dz.PRIORITY_HIGH
)
end
end
}
Evertjob89 wrote: ↑Monday 17 December 2018 16:37
Currently i'm running an setup with a NPN watermeter sensors and this works fine.
I'm looking for a script that could help me but because i don't get DzVents as everyone else (maybe i'm thinking to difficult?) but the idea should be The idea is very simple, but i'm not getting it working (And i would like to not test it for 17 minutes)
Modified the calculation of current flow. Can you try this ? and please check the log for a couple of hours to see if factor is set right for your meter.
return {
on = { devices = { "Watermeter" }},
data = { watermeter = { history = true, maxHours = 2 }},
logging = {
level = domoticz.LOG_DEBUG,
marker = "watermeter"
},
execute = function(dz,item)
local function logWrite(str,level)
dz.log(tostring(str),level or dz.LOG_DEBUG)
end
-- JSON call to emulate waterflow
-- http://192.168.192.51:8084/json.htm?type=command¶m=udevice&idx=1242&svalue=0
dz.data.watermeter.add(item.counter)
local minutes = 17
local maxLitersPerMinute = 5.5
local factor = 100
local max = dz.data.watermeter.maxSince('00:'.. minutes .. ':00')
local min = dz.data.watermeter.minSince('00:'.. minutes .. ':00')
local litersPerMinuteNotify = (max - min) / minutes * factor
local current = dz.data.watermeter.get(1).data
local previous, previousTime, litersPerMinuteNow
if dz.data.watermeter.get(2) ~= nil then
previous = dz.data.watermeter.get(2).data
previousTime = dz.data.watermeter.get(2).time.msAgo
litersPerMinuteNow = (( current - previous ) / (previousTime / 60000 )) * factor -- 60000 = msecs in a minute
logWrite("Current water usage: " .. dz.utils.round(litersPerMinuteNow,1) .. " liter a minute")
else
logWrite("Current water usage cannot be determined (not enough data in history)")
end
if litersPerMinuteNotify > maxLitersPerMinute then
dz.notify (
'Water usage high!!',
'The waterusage is ' .. dz.utils.round(litersPerMinuteNotify,1) .. ' liter a minute!',
dz.PRIORITY_HIGH
)
end
end
}
I've tried it and it works, only not as i thought: I've want an average (Usage / Time = Result) for the last 17 minutes, right know it's giving me the result for every minute:
Evertjob89 wrote: ↑Tuesday 18 December 2018 16:08
I've tried it and it works, only not as i thought: I've want an average (Usage / Time = Result) for the last 17 minutes, right know it's giving me the result for every minute:
What you see is debug information. These are the values calculated every time the script executes.
If the water usage is above the set average (5.5) for the set period (17 minutes ) the script should send a notification.
If you want to test you can lower these settings by modifying the lines
if litersPerMinuteNotify > maxLitersPerMinute then
--I added here
execute = function(domoticz, alert_woda)
local alarmwoda = domoticz.devices('Woda Alarm')
alarmwoda.switchOn()
end
But switch state Off and no errors. What i am doing wrong
if litersPerMinuteNotify > maxLitersPerMinute then
--I added here
execute = function(domoticz, alert_woda)
local alarmwoda = domoticz.devices('Woda Alarm')
alarmwoda.switchOn()
end
But switch state Off and no errors. What i am doing wrong
You don't need the repetition of the execute section. Just use
My friend got bill 200E for water. 2 times. After that he discovered that he had very little leakage from woodburner where is water valve for emergence. If there is power cut and woodburner is full of burning wood and pump stop pumping hot water, woodburner could explode so thermovalve open cold water for cooling stove. That valve opened just a little and he had very little leakage for very long time directly to sewage pipe so he could not spoted it. I have the same valve in my stove. How to check database water usage if there is no 0 usage during 24h for example?
rodaman wrote: ↑Tuesday 18 February 2020 15:40
I was thinking like, it should be 0 (zero) liter at some point in 24 hours. If there is liittle leakage it will never be 0. Am I wrong?
I guess you are right but how long do you want to monitor the meter before you conclude the usage you measure is from a leak and not from common usage ?
During 24 hours I would like check if there is 0 liters usage. It should be especially in the night in my case . If 0 never occur for given time- alarm.
rodaman wrote: ↑Tuesday 18 February 2020 15:53
During 24 hours I would like check if there is 0 liters usage. It should be especially in the night in my case . If 0 never occur for given time- alarm.
Probably a language thing but I try to understand what your definition is for 'given time'. Is it 3 days, a week, a month or something else ?
Ok, sorry. Let say 24 hours because I can see in a daily Domoticz report every night I have zero usage at some point so I do not have a little leakage. No need immediate action, just check if 0 occured during last 24 hours. Maybe I am wrong but I thought Domoticz keep detailed values for 24 hrs.
rodaman wrote: ↑Tuesday 18 February 2020 16:27
Ok, sorry. Let say 24 hours because I can see in a daily Domoticz report every night I have zero usage at some point so I do not have a little leakage. No need immediate action, just check if 0 occured during last 24 hours. Maybe I am wrong but I thought Domoticz keep detailed values for 24 hrs.
You could try this. It should notify you when there was no water usage in the last 24 hours.
Don't expect a notification the first time. The value is initialized then.
local watermeterName = 'Watermeter' -- device name of watermeter
return
{
on =
{
timer =
{
'at 22:00',
},
devices =
{
watermeterName
},
},
data =
{
waterTotal = { initial = 0 },
watermeter = { history = true, maxHours = 2 },
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'watermeter',
},
execute = function(dz, item)
local function logWrite(str,level)
dz.log(tostring(str),level or dz.LOG_DEBUG)
end
-- JSON call to emulate waterflow
-- http://192.168.192.51:8084/json.htm?type=command¶m=udevice&idx=1242&svalue=0
if item.isTimer then
local watermeter = dz.devices(watermeterName)
if watermeter.counter == dz.data.waterTotal then
logWrite("No water usage today")
dz.notify ('Water usage', 'There was no waterusage today', dz.PRIORITY_NORMAL )
else
dz.data.waterTotal = watermeter.counter
end
return
end
dz.data.watermeter.add(item.counter)
local minutes = 17
local maxLitersPerMinute = 5.5
local factor = 100
local max = dz.data.watermeter.maxSince('00:'.. minutes .. ':00')
local min = dz.data.watermeter.minSince('00:'.. minutes .. ':00')
local litersPerMinuteNotify = (max - min) / minutes * factor
local current = dz.data.watermeter.get(1).data
local previous, previousTime, litersPerMinuteNow
if dz.data.watermeter.get(2) ~= nil then
previous = dz.data.watermeter.get(2).data
previousTime = dz.data.watermeter.get(2).time.msAgo
litersPerMinuteNow = (( current - previous ) / (previousTime / 60000 )) * factor -- 60000 = msecs in a minute
logWrite("Current water usage: ' .. dz.utils.round(litersPerMinuteNow,1) .. ' liter a minute")
else
logWrite("Current water usage cannot be determined (not enough data in history)")
end
if litersPerMinuteNotify > maxLitersPerMinute then
dz.notify (
'Water usage high!!',
'The waterusage is ' .. dz.utils.round(litersPerMinuteNotify,1) .. ' liter a minute!',
dz.PRIORITY_HIGH
)
dz.devices('Woda Alarm').switchOn()
end
end
}
Thank you for the script. I was thinking more that notification should be when non "0" occur during 24hrs. It could be sign that I have constant usage, very small but constant. What is "waterTotal" as a value. Maybe I can figure out how to write the script by me. I am very appreciated for your help.