Sticks18
(Scott G)
January 1, 2015, 11:41pm
3
I agree with @minollo . Using runIn with intervals < 60 seconds has been an issue for many. Try using runOnce instead. 60 actions that quickly back to back might cause some lag though, so good luck!
I’m trying to detect a long press (held down for more than 3 seconds) on a button. To do this, I have the following code:
def pushHandler(evt) {
log.debug "$evt.name: $evt.value"
if (evt.value == "pushed") {
// Do something if its still pressed in 3 seconds
log.debug "starting runIn timer"
state.pressed = now()
runIn(3, stillPressed)
}
else if ((evt.value == "released") || (evt.value == "off")) {
if (!state.pressed) {
log.debug "release after long press, doing nothing"
}
else {
log.debug "unscheduling"
state.pressed = null
unschedule(stillPressed)
log.debug "normal press, do something"
}
}
}
def stillPressed() {
log.debug "called still pressed"
…