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
Doorbell in Domoticz with window sensor
Moderator: leecollings
-
domogijs
- Posts: 99
- Joined: Monday 17 August 2015 23:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Doorbell in Domoticz with window sensor
Raspberry Pi3, RFlink, PiZigate, Yeelight, klikaanklikuit, Kodi, harmony hub, Zwave, ThermoSmart, XiaomiGateway (Aqara), Google home hub, roomba,
-
dannybloe
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Doorbell in Domoticz with window sensor
Look into the historical persisten data support in dzVents. You can use that.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
domogijs
- Posts: 99
- Joined: Monday 17 August 2015 23:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Doorbell in Domoticz with window sensor
Ok thanks will do, right now I can't see my gateway anymore so I have to fix that first.
Raspberry Pi3, RFlink, PiZigate, Yeelight, klikaanklikuit, Kodi, harmony hub, Zwave, ThermoSmart, XiaomiGateway (Aqara), Google home hub, roomba,
-
domogijs
- Posts: 99
- Joined: Monday 17 August 2015 23:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Doorbell in Domoticz with window sensor
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]Raspberry Pi3, RFlink, PiZigate, Yeelight, klikaanklikuit, Kodi, harmony hub, Zwave, ThermoSmart, XiaomiGateway (Aqara), Google home hub, roomba,
-
dannybloe
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Doorbell in Domoticz with window sensor
This part is not correct:
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:
Of course you won't be notified if the person presses the doorbell again within 10s. But that's not a problem I guess.
Code: Select all
domoticz.data.counter = 0 .afterSec(20)-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
}
}
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
domogijs
- Posts: 99
- Joined: Monday 17 August 2015 23:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Doorbell in Domoticz with window sensor
This is exactly what I need!
Thanks! Keep up the good work with dzvents. I will try to develop with less help
Greets Gijs
Thanks! Keep up the good work with dzvents. I will try to develop with less help
Greets Gijs
Raspberry Pi3, RFlink, PiZigate, Yeelight, klikaanklikuit, Kodi, harmony hub, Zwave, ThermoSmart, XiaomiGateway (Aqara), Google home hub, roomba,