Ecolink Z-Wave plus *ALMOST* always throws duplicate messages


(Mike) #1

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

Anyone have a solution?? thanks


(jkp) #2

Open the device, then select SmartApps in the upper menu. There you should find every app using it that could be sending a notification.


(Mike) #3

No I don’t think that’s it. I opened a brand new sensor just now and connected it to my hub. That’s the log of the device itself.


#4

Yes, I see this too sometimes. A bug I think.


(jkp) #5

I am only seeing one message on mine. I must admit that I only use the zwave Door/window sensor device handler and not the zwave plus one.


(John C) #6

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.

Just a hunch, no proof!


(Mike) #7

Yeah so possible solutions:

  1. buy a different brand / model of sensor
  2. put some hacky code in my SmartApp to ignore the second device message. Something like:
    def lastTime = state[evt.deviceId]
    if (lastTime == null || now() - lastTime >= 1000) {
        // fire the message otherwise it's too soon so ignore
    }

I’ll give that a try and report back


(Mike) #8

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}")

(Mike) #9

here’s the full repo: https://github.com/findmory/smartthings-sensor_open_close/tree/master