Page 1 of 1
Proper way to limit notifications in DzVents?
Posted: Friday 26 June 2020 9:39
by Jumper3126
Hi all
I have a script to control my greenhouse, which runs every minute. If the humidity or temp is critical, it should take action
and inform me. But i dont want to get a message every minute till it is solved.
I now have this line to limit the number of notifications send to 1 in 15 minutes.
Code: Select all
if (domoticz.time.matchesRule('every 15 minutes')) then domoticz.notify('Too dry! Serre humidity <50%', domoticz.PRIORITY_HIGH) end
Is this a proper way to do so in DzVents, or is there a better solution to only receive the first notification and then stop sending for 15 minutes. What is the impact if I use this line for multiple, independent conditions that may happen the same time (like humidity is too low, but also temp is too high). Will the 15 minute limit apply to each line independently?
Re: Proper way to limit notifications in DzVents?
Posted: Sunday 28 June 2020 14:15
by waaren
Jumper3126 wrote: Friday 26 June 2020 9:39
Is this a proper way to do so in DzVents, or is there a better solution to only receive the first notification and then stop sending for 15 minutes.
You could do it like below
Code: Select all
return
{
on =
{
timer =
{
'every minute',
},
},
logging =
{
level = domoticz.LOG_DEBUG,
},
data =
{
notifications =
{
initial = {},
},
},
execute = function( dz )
local function managedNotification(id, message,interval,priority)
local interval = interval or 15
local priority = priority or dz.PRIORITY_HIGH
if dz.data.notifications[id] == nil or dz.data.notifications[id] < dz.time.dDate then
dz.notify('managedNotification -- [' .. id ..']', message, priority)
dz.data.notifications[id] = dz.time.dDate + interval * 60
end
end
managedNotification('greenhouse','Too dry! Serre humidity <50%') -- using default interval and default priority
managedNotification('living Room','Cold', 30 , dz.PRIORITY_LOW) -- overriding defaults
end
}
Re: Proper way to limit notifications in DzVents?
Posted: Sunday 28 June 2020 21:24
by Jumper3126
Thanks waaren,
Do I understand correctly, that the interval counts per id? So in the example above, the timer for greenhouse and livingroom are independent. But if
would have the same id, the second line would base its timer on the first line?
Re: Proper way to limit notifications in DzVents?
Posted: Sunday 28 June 2020 21:46
by waaren
Jumper3126 wrote: Sunday 28 June 2020 21:24
Thanks waaren,
Do I understand correctly, that the interval counts per id? So in the example above, the timer for greenhouse and livingroom are independent.
Yes
But if
would have the same id, the second line would base its timer on the first line?
I don't understand this question. Please elaborate
Re: Proper way to limit notifications in DzVents? [Solved]
Posted: Monday 29 June 2020 21:20
by Jumper3126
Basically you already answered it with your YES
Thanks