ok it required working with atomicState, but basically I am storing the timestamp of when I last handled an event for this device. When I go to handle a new event I look to see if it’s been at least 500ms and only send the notification if so. Final code something like this:
// handle null
if (!atomicState.lastExecution) {
atomicState.lastExecution = 0
}
// if we have just handled this same event within 500ms ignore it
if (now() - atomicState.lastExecution <= 500) {
log.trace('too soon so skipping')
return
}
// update state for the time we are handling the event
atomicState.lastExecution = now()
def now = new Date()
def nowFormatted = now.format('EEE, MMM d HH:mm:ss Z',TimeZone.getTimeZone('America/New_York'))
sendSms(phone1, "Your ${contact1.label ?: contact1.name} was closed at ${nowFormatted}")