Finished some testing. A virtual debouncer may be the way to go. My testing indicates that the events are so close together that it the Event has not changed and that private boolean has not been changed (not unexpected, but self-verified). To document the trivial:
A. Created a Virtual Alarm Drver
/*
A virtual contact debouncer to eliminate multiple rule execution
*/
metadata {
definition (name: "AA Virtual Alarm Driver",namespace: "me",author: "me"
) {
capability "ContactSensor"
command "opened"
}
}
def opened() {
log.info "Debouncer triggered"
// You can play with the runIn to optimize your installation.
runIn(1, startAlarm)
}
def startAlarm() {
log.info "startAlarm Executed"
sendEvent(name: "contact", value: "open")
runIn(2, closed)
}
def closed() {
log.info "Debouncer closed"
sendEvent(name: "contact", value: "closed")
}
B. Created a virtual device that is linked to this driver.
C. Created the two rules below (in the second, the log message
(Note the Log can be any action).
D. Set up my virtual contact sensor to send 5 open events as fast as possible. I also tried for 10 ms pause with same result.
dev:51752020-04-05 03:28:52.178 pm infoDebouncer closed
app:32912020-04-05 03:28:50.349 pm infoThe Siren Has Been Activated
dev:51752020-04-05 03:28:50.089 pm infostartAlarm Executed
dev:51752020-04-05 03:28:49.098 pm infoDebouncer triggered
dev:51752020-04-05 03:28:49.048 pm infoDebouncer triggered
dev:51752020-04-05 03:28:49.000 pm infoDebouncer triggered
dev:51752020-04-05 03:28:48.906 pm infoDebouncer triggered
dev:51752020-04-05 03:28:48.829 pm infoDebouncer triggered
dev:51102020-04-05 03:28:48.231 pm infoOpened, count = 5
dev:51102020-04-05 03:28:48.228 pm infoOpened, count = 4
dev:51102020-04-05 03:28:48.225 pm infoOpened, count = 3
dev:51102020-04-05 03:28:48.222 pm infoOpened, count = 2
dev:51102020-04-05 03:28:48.218 pm infoOpened, count = 1
Going from bottom, note the five open events sent to system. Followed by 5 triggered events caused by the Rule Machine, followed by a SINGLE Siren, then the debouncer closed. If I use 10 msec delay between events, I get only two triggers in the debouncer.
This runIn of 1 second is ok for a single device. May cause problems for multiple sensors (i.e., wife comes in front at same time as hubby comes in at garage. But...