Missing events (zwave homeseer WD100+ device handler reports creation handler is only called the first time...)

Hi everyone,

I’ve been using smartthings for a while mostly to control a number of HomeSeer WD100+ dimmers and WS100+ switches. I’m using the darwinsden device handler from https://github.com/DarwinsDen/SmartThingsPublic/blob/master/devicetypes/darwinsden/wd100-dimmer.src/wd100-dimmer.groovy and the associated one for the switches, though I’ve only been trying to debug the dimmer performance so far.

I’ve written a smart app which parses the returns from the buttons on the dimmers and sends events to lists of connected switches So I can turn other dimmers or switches off with double and triple taps. The thing is the app has worked perfectly fine for years and has suddenly stopped functioning correctly. I’ve tried removing and re-adding the switches to the zwave network but it hasn’t helped. Even more strangely the smart app does seem to work sometimes if the hub is just rebooted or I change save and publish the smart app or device handler but it isn’t consistent. Looking at the logging I can see that the device handler is reporting the events and I have a log.debug statement at the very beginning of the handler function in the smart app that doesn’t get called except for those rare occasions. It’s as if the first action event per switch doesn’t get cleared from an event queue and the handler is simply never called for follow on events, but there doesn’t seem to be anything I can do to affect that (I also have a log.debug statement at the end of the handler function which is called so I’m sure I’m not stuck processing a loop or something.) I’ve ordered a ZStick and bought the Homeseer app to update the firmware on the switches but that really shouldn’t be an issue given the device handler is running and receiving the double and triple taps.

I tried to generate some example logging data but the works the first time thing is very hit or miss and obviously once I started writing this it stopped working completely. The device handler does report event creation with items like:

Parse returned [[name:button, value:pushed, data:[buttonNumber:1], descriptionText:Bedroom dimmer Tap-Up-2 (button 1) pressed, isStateChange:true, type:physical, displayed:true, linkText:Bedroom dimmer]]

My current code is (I’ve made a few relatively random changes over time… used to return when an unhandled button was pressed but wanted to make sure execution was going all the way through so I recently changed it to keep going to the end with a null list of things to change):

/**
 *  HomeSeerSwitchLink 
 *
 *  Copyright 2016 reenigne
 *
 *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
 *  on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
 *  for the specific language governing permissions and limitations under the License.
 *
 */
 
import groovy.json.JsonSlurper
 
definition(
    name: "HomeSeerSwitchLink",
    namespace: "reenigne",
    author: "reenigne",
    description: "Links up and down double and triple taps on a Homeseer zwave switch to other switches",
    category: "Convenience",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
    iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")


preferences {
	section("Connect switches") {
		input "theButton","capability.button",title:"Which switch will be in control?", required:true
        input "doubleSwitches","capability.switch",title:"Which switch(es) will be toggled for double taps?", multiple:true, required:false
        input "tripleSwitches","capability.switch",title:"Which switch(es) will be toggled for triple taps?", multiple:true, required:false
        
	}
}

def installed() { log.debug "Installed with settings: ${settings}"

 initialize() }

def updated() {
	log.debug "Updated with settings: ${settings}"

	unsubscribe()
	initialize()
}

def initialize() {
	log.info("initializing My Smart App")
	subscribe(theButton,"button",onPressed)
}

def onPressed(evt){
    if (!evt.data) {
        log.debug ("leaving onPressed Early No data")
        return
    }
    log.debug("onPressed:$evt.data")

    def slurper = new JsonSlurper()
    def data = slurper.parseText(evt.data)
    def buttonNum = 20
    buttonNum = data?.buttonNumber?.toInteger()

    def turnOn = false
    def switchList = doubleSwitches
    switch(buttonNum){
    case 1:
	turnOn = true;
    break
    case 2:
    break
    case 3:
    switchList = tripleSwitches
    turnOn = true
    break
    case 4:
    switchList = tripleSwitches
    break
    case 5:
    case 6:
    case 7:
    case 8:
    switchList = null;
    default:
    log.debug("error: button parsing didn't work correctly")
	log.debug(buttonNum)
    return;
    }
    if(turnOn){
    if(switchList == null){ return}
    for(theSwitch in switchList){
    	theSwitch.on()
    	}
    }
    else{
    if(switchList == null){ return}
    for(theSwitch in switchList){
    	theSwitch.off()
    	}
    }
    log.debug("end of smart app exec")
 }

I came to the sudden realization that as the Dimmer switches show up as buttons I could use the smartthings button controller smart app. This app also doesn’t work…

I was able to get some logging output that shows it sometimes works though. You can see that the Parse debug statement indicates a button press then the smartthings button handler smart app runs an Ensuite On routine I setup which did in fact turn on that light. Then I did a double tap down which you can see was parsed as button 2 and nothing happened afterwards (it is bound to an Ensuite Off routine.):

 50e60e5b-693b-401b-ae9c-43943ac339f2  12:01:18 PM: debug Parse returned [[name:button, value:pushed, data:[buttonNumber:2], descriptionText:Bedroom dimmer Tap-Down-2 (button 2) pressed, isStateChange:true, type:physical, displayed:true, linkText:Bedroom dimmer]]
 50e60e5b-693b-401b-ae9c-43943ac339f2  12:01:18 PM: debug sceneNumber: 2 keyAttributes: 3
 50e60e5b-693b-401b-ae9c-43943ac339f2  12:01:18 PM: debug zw device: 0A, command: 5B03, payload: 60 03 02
 50e60e5b-693b-401b-ae9c-43943ac339f2  12:01:18 PM: debug sceneNumber: 2 keyAttributes: 3
 50e60e5b-693b-401b-ae9c-43943ac339f2  12:01:18 PM: debug zw device: 0A, command: 5B03, payload: 60 03 02
 6cec5fd8-f550-4311-9b81-ca974e8370f6  12:01:16 PM: debug Parse returned [descriptionText:Basement Near Router MSR: 000C-4447-3033, isStateChange:false, displayed:false, linkText:Basement Near Router]
 6cec5fd8-f550-4311-9b81-ca974e8370f6  12:01:16 PM: debug productTypeId: 17479
 6cec5fd8-f550-4311-9b81-ca974e8370f6  12:01:16 PM: debug productId: 12339
 6cec5fd8-f550-4311-9b81-ca974e8370f6  12:01:16 PM: debug manufacturerName: HomeSeer Technologies
 6cec5fd8-f550-4311-9b81-ca974e8370f6  12:01:16 PM: debug manufacturerId: 12
 6cec5fd8-f550-4311-9b81-ca974e8370f6  12:01:16 PM: debug productTypeId: 17479
 6cec5fd8-f550-4311-9b81-ca974e8370f6  12:01:16 PM: debug productId: 12339
 6cec5fd8-f550-4311-9b81-ca974e8370f6  12:01:16 PM: debug manufacturerName: HomeSeer Technologies
 6cec5fd8-f550-4311-9b81-ca974e8370f6  12:01:16 PM: debug manufacturerId: 12
 6cec5fd8-f550-4311-9b81-ca974e8370f6  12:01:15 PM: debug Parse returned [name:switch, value:off, type:digital, isStateChange:false, displayed:false, linkText:Basement Near Router, descriptionText:Basement Near Router switch is off]
 6cec5fd8-f550-4311-9b81-ca974e8370f6  12:01:15 PM: debug Parse returned [name:switch, value:off, type:digital, isStateChange:false, displayed:false, linkText:Basement Near Router, descriptionText:Basement Near Router switch is off]
 ddb533e8-99f7-4893-9a5b-66c33fd4972c  12:01:06 PM: debug Parse returned [[name:switch, value:on, isStateChange:true, displayed:true, linkText:Ensuite dimmer, descriptionText:Ensuite dimmer switch is on], [name:level, value:1, unit:%, isStateChange:false, displayed:false, linkText:Ensuite dimmer, descriptionText:Ensuite dimmer level is 1%]]
 ddb533e8-99f7-4893-9a5b-66c33fd4972c  12:01:06 PM: debug zw device: 0B, command: 2603, payload: 01
 ddb533e8-99f7-4893-9a5b-66c33fd4972c  12:01:06 PM: debug Parse returned [[name:switch, value:on, isStateChange:true, displayed:true, linkText:Ensuite dimmer, descriptionText:Ensuite dimmer switch is on], [name:level, value:1, unit:%, isStateChange:false, displayed:false, linkText:Ensuite dimmer, descriptionText:Ensuite dimmer level is 1%]]
 ddb533e8-99f7-4893-9a5b-66c33fd4972c  12:01:06 PM: debug zw device: 0B, command: 2603, payload: 01
 0ea4fb42-476b-46df-b485-3da6a08ee2d6  12:01:00 PM: debug Found: false for notifications_1_pushed
 0ea4fb42-476b-46df-b485-3da6a08ee2d6  12:01:00 PM: debug Found: Ensuite On for phrase_1_pushed
 0ea4fb42-476b-46df-b485-3da6a08ee2d6  12:01:00 PM: debug executeHandlers: 1 - pushed
 0ea4fb42-476b-46df-b485-3da6a08ee2d6  12:01:00 PM: debug Found 1 events in past 3 seconds
 0ea4fb42-476b-46df-b485-3da6a08ee2d6  12:01:00 PM: debug button: {"buttonNumber":"1"}, value: pushed
 0ea4fb42-476b-46df-b485-3da6a08ee2d6  12:01:00 PM: debug buttonEvent: button = pushed ({"buttonNumber":"1"})
 0ea4fb42-476b-46df-b485-3da6a08ee2d6  12:01:00 PM: trace timeOk = true
 0ea4fb42-476b-46df-b485-3da6a08ee2d6  12:01:00 PM: trace daysOk = true
 0ea4fb42-476b-46df-b485-3da6a08ee2d6  12:01:00 PM: trace modeOk = true
 50e60e5b-693b-401b-ae9c-43943ac339f2  12:01:00 PM: debug Parse returned [[name:button, value:pushed, data:[buttonNumber:1], descriptionText:Bedroom dimmer Tap-Up-2 (button 1) pressed, isStateChange:true, type:physical, displayed:true, linkText:Bedroom dimmer]]

After giving up but being curious I’ve noticed that the switch I have setup will suddenly work once and then stop working again. For example after writing a post on here I can turn on the Ensuite light with the bedroom switch but if I immediately double tap down the smart app isn’t called. If I wait a minute or so it still doesn’t work. If I wait for several minutes (not sure the cut off) the smart app will work once and then require… rest?. The only explanation I can come up with is that an event queue isn’t big enough or events aren’t handled fast enough to keep up with the switch (which makes little sense as there are very few messages coming from the switch and right now I’m using a smartthings provided button handler). Not sure if anyone has run into anything like this before or if it’s even something that can be fixed using custom code…