bbubble62
(bbubble62)
November 16, 2016, 7:07pm
1
Hi,
In my garden I have a motion sensor, everytime it sees a movement it will trigger (CLOSE -->OPEN) and plays a sound.
Now I want to add a delay so it doesn’t play a sound every movement but (example) only after 5 minutes again.
So the ‘retrigger’ should be disabled for 5 minutes, I tried several things with createTimer but cannot get it done.
Any idea’s ?
-ben
rlkoshak
(Rich Koshak)
November 16, 2016, 7:52pm
2
See the following:
rlkoshak:
This one is a little tricky. I think the Latch design pattern would be the best approach. This looks like what you are trying to do. There are a couple of ways to implement this. I would probably use a timer. var Timer colourtimer = null rule "really changed?" when Item Esp_Colour changed then if(colourtimer == null || colourtimer.hasTerminated) { sendNotification("my_email", "New colour = " + Esp_Colour.state.toString) colourtimer = createTimer(now.plusMinutes(20), […
The short of it is use a lock or a Timer and in the rule check to see if the lock is locked or the Timer is running and if it is skip the rule.
bbubble62
(bbubble62)
November 16, 2016, 9:22pm
3
Hi Rich,
With your link i’ve created the following :
var Timer timer1 = null
rule "Motion detection backyard"
when
Item pirSensor1 changed to OPEN
then
if(timer1 == null) {
playSound("doorbell.mp3")
timer1 = createTimer(now.plusMinutes(1)) [|
timer1 = null
]
}
end
After 1st trigger (change to open), it won’t trigger until timer1 ( +1 minute) expires.
-ben