I’ve tried various positions, magnet distances, and reset (include/exclude)… but I have two identical Ecolink Z-Wave sensors and pretty much every time they open or close they fire TWO messages. i.e. OPEN OPEN or CLOSE CLOSE
For a long time now, I’ve suspected these “double messages” are intentional in the ST architecture to improve the odds of message delivery. If the first one fails (perhaps due to throughput issues), maybe the second will get there in time.
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}")