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