I just saw this solution in another thread which should work for this as well.
import java.util.concurrent.locks.Lock
import java.util.concurrent.locks.ReentrantLock
var Lock lock = new ReentrantLock()
rule "garage proxy"
when
Item Garage received command
then
// tryLock will acquire the lock if it is available, and fail fast otherwise.
if (lock.tryLock()) {
Garage.sendCommand(ON)
Thread::sleep(30000)
lock.unlock()
} else {
logInfo("Garage", "Garage button currently disabled")
}
end
This uses a Reentrant Lock to disable the rule. A Rule triggers in one thread, grabs the lock, sends the command to the “real” garage switch, sleeps for 30 seconds and gives up the lock. Any subsequent rule triggers while the first one is sleeping will simply jump to the else clause.