Page 1 of 1
Doorbell in Domoticz with window sensor
Posted: Wednesday 14 February 2018 20:18
by domogijs
Hi
Because a doorbell works with an electronic magnet I taped a window sensor on it. It works like a charm. When doorbell is pressed I get activity in Domoticz. So I made a script to send me a notification when doorbell is pressed.
Problem is, when doorbell is pressed there are a lot on, off,on, off (like 25) readings in Domoticz. And every time the script processed. Is there an way to process this script only on time in like 5 sec?
Greets Gijs
Re: Doorbell in Domoticz with window sensor
Posted: Wednesday 14 February 2018 20:29
by dannybloe
Look into the historical persisten data support in dzVents. You can use that.
Re: Doorbell in Domoticz with window sensor
Posted: Tuesday 20 February 2018 10:22
by domogijs
Ok thanks will do, right now I can't see my gateway anymore so I have to fix that first.
Re: Doorbell in Domoticz with window sensor
Posted: Friday 23 February 2018 19:21
by domogijs
Ok this is my code right now but is doesn't work. Some thing is wrong with the aftersec command. If I understand the wiki right you can use it in combination with the counter command.
Code: Select all
return {
on = {
devices = { 'Switch B' }
},
data = {
counter = { initial = 0 }
},
execute = function(domoticz, devices)
if (domoticz.data.counter == 5) then
domoticz.notify('doorbell')
domoticz.data.counter = domoticz.data.counter + 1
domoticz.data.counter = 0 .afterSec(20)-- reset the counter after 20 sec
else
domoticz.data.counter = domoticz.data.counter + 1
end
end
}
[Code]
Re: Doorbell in Domoticz with window sensor
Posted: Saturday 24 February 2018 8:58
by dannybloe
This part is not correct:
Code: Select all
domoticz.data.counter = 0 .afterSec(20)-
You can only use afterSec with device(updates). Data changes are always immediate as there is no scheduling system for this in place.
I think you should take a different approach here. What you can do is only notify if the lastUpdate of the switch is more than x seconds ago:
Code: Select all
return {
on = {
devices = { 'Switch B' }
},
execute = function(domoticz, switch)
if (switch.active and switch.lastUpdate.secondsAgo > 10) then
domoticz.notify('doorbell')
end
}
}
Of course you won't be notified if the person presses the doorbell again within 10s. But that's not a problem I guess.
Re: Doorbell in Domoticz with window sensor
Posted: Saturday 24 February 2018 20:17
by domogijs
This is exactly what I need!
Thanks! Keep up the good work with dzvents. I will try to develop with less help
Greets Gijs