That throws an error. But this seems to be working reliably:
import groovy.time.TimeCategory
def switchHandler(evt) {
log.debug "in event handler"
if (state.gotON) {
unschedule()
fireDouble()
} else {
state.gotON = true
def timer = new Date()
use(TimeCategory) {
timer = timer + 3.second
}
runOnce(timer, "fireSingle")
}
}
def fireSingle() {
log.debug "firing single"
state.gotON = null
}
def fireDouble() {
log.debug "firing double"
state.gotON = null
}
UPDATE: Yup… working like a charm. See this post for more info and the final app.