Homeseer HS-WD200 Dimmer Button Mapping

The correct Led turns on, the correct color displays but no blink.


Hmm, I misinterpreted something in their manual, but I also see where there was a typo in the original DTH above (they were ORing a bitmask instead if ANDing it to un-do the calculated/stored "which LEDs are blinking?" parameter, and I now understand why they were tracking that since I missed that each one is indivudally settable this way). Here's another try. Hope it improves things!

[EDIT: Further revisions are below]

Still no change on the blinking.

Yes, that makes perfect sense, ORing / ANDRing :confused: lol.

I wonder if it's reading an old/bad stored "blink value" from state. Can you add a state.blinkval = 0 line to the updated() method of the driver, hit "Save Preferences" in the driver, then remove that line and try again? Or I can post a quick modification that does that too.

I am doing some tests now, but I think that did it...

I don't know how to thank you, let me know how...

It now works, this driver meets my needs.

:grinning:

1 Like

Hello! I am also trying this driver. Ideally I want to be able to handle 3-4-5 taps with the physical switch. Right now when I do one of those (like a triple tap) there is no log entry made, so I don't think it's being captured.

I pulled off the latest version you posted towards the bottom here, and tested that blinking works.

Also, when I press the "Push" button on the Device page with any entry, I get this error:

error groovy.lang.MissingMethodException: No signature of method: user_driver_homeseer_WD200__Dimmer_CUSTOM_387.push() is applicable for argument types: (java.math.BigDecimal) values: [0]
Possible solutions: push(java.lang.Integer), use([Ljava.lang.Object;), run(), poll(), run(), dump() (push)

(I tried it with a null input and I get the log message that the number is not in range. But with an actual integer I get the error above).

In the end, I am trying to get this to work through Webcore.

I am starting to think that multiple presses (other than single and double taps) are not supported! But assigning the multiple taps to different buttons should work, right?

Update: I googled a bit, then removed the "Integer" from "push(Integer button)" and the method works. The other methods that have Integer defined are not working, so it looks like Groovy doesn't like that declaration (I am not a groovy fan).

However, that only works when I press the button through the Device page interface.

When I actually multiple tap the button, I am getting this (5 taps):

[dev:32](http://192.168.1.148/logs#dev32)2020-11-30 08:14:25.705 pm [debug](http://192.168.1.148/device/edit/32)Parse returned [:] for command null

[dev:32](http://192.168.1.148/logs#dev32)2020-11-30 08:14:25.700 pm [debug](http://192.168.1.148/device/edit/32)skip: SupervisionGet(statusUpdates:false, reserved:0, sessionID:12, commandLength:5, commandClassIdentifier:91, commandIdentifier:3, commandByte:[63, 134, 1])

[dev:32](http://192.168.1.148/logs#dev32)2020-11-30 08:14:25.691 pm [debug](http://192.168.1.148/device/edit/32)parse() for: zw device: 31, command: 6C01, payload: 0C 05 5B 03 3F 86 01 , isMulticast: false

I'm just starting out on this platform, but it looks like this:

def cmd = zwave.parse(description, commandClassVersions)

Is failing to return a result. I suspect that this is a Hubitat library function and that this in an unsupported event?

OK, sorry. It's parsing correctly as far as I can tell, but then it's not calling the matching zwaveEvent:

This first line is the parse, which is the cmd, the second line is where it was picked up

dev:322020-11-30 08:48:39.818 pm debug parse() for: zw device: 31, command: 6C01, payload: 18 05 5B 03 49 86 01 , isMulticast: false
dev:322020-11-30 08:48:39.831 pm debug skip: SupervisionGet(statusUpdates:false, reserved:0, sessionID:24, commandLength:5, commandClassIdentifier:91, commandIdentifier:3, commandByte:[73, 134, 1])

That shows this was picked up by the catch-all:

zwaveEvent(hubitat.zwave.Command cmd)

And not:

zwaveEvent(hubitat.zwave.commands.centralscenev1.CentralSceneNotification cmd)

I also attempted to use v2 and v3, but none of them matched on that packet.

So I checked the implentation...

ST implemented V1 (only) and implemented like this

class physicalgraph.zwave.commands.centralscenev1.CentralSceneNotification {
  Short keyAttributes
  Short sceneNumber
  Short sequenceNumber
  List<Short>payload

  String format()
}

However, it looks like Hubitat implements like this:

 class hubitat.zwave.commands.centralscenev1.CentralSceneNotification {
     Short keyAttributes
     Short sceneNumber
     Short sequenceNumber
     static Short KEY_HELD_DOWN = 2
     static Short KEY_PRESSED_1_TIME = 0
     static Short KEY_RELEASED = 1
 
     List<Short> getPayload()
     String format()
 }

So the two differences are the statics and the payload Vs getPayload().

Would groovy not match on these for some reason?

(I even tried moving the definition of the catch all AFTER this handler, but it didn't work- as expected)

Makes sense. I wasn't handling SupervisionGet in my attempt at porting the driver. This is hard without the device. :laughing:

This might help. I also fixed the push() and held() commands, so they should work with any numeric type now.

[EDIT: New revision below]

Thank you! I'll give it a shot later tonight.

Can I ask what you did to get the event to match the centralscene notification? I don't have the old code on front of me here, but the declaration looks the same. It looks like each of the events are overloaded using the class... But did the class definition change?

I didn't modify anything with CentralSceneNotification, so you you aren't missing anything there. The issue is that a SupervisionGet would contain an encapsulated command, which this driver was previously not handling (just discarding). Now it should unencapsulate those and pass the report, if any, along to whatever method would ordinarily handle the contents--which was apparently scenes (and probably more), explaining why those wouldn't work.

Getting close!

[dev:32](http://192.168.1.148/logs#dev32)2020-12-01 02:53:27.369 am [error](http://192.168.1.148/device/edit/32)groovy.lang.MissingMethodException: No signature of method: user_driver_homeseer_WD200__Dimmer_CUSTOM_387.command() is applicable for argument types: (hubitat.zwave.commands.supervisionv1.SupervisionReport) values: [SupervisionReport(moreStatusUpdates:false, reserved:0, sessionID:43, status:255, duration:0)] on line 213 (parse)

[dev:32](http://192.168.1.148/logs#dev32)2020-12-01 02:53:27.336 am [debug](http://192.168.1.148/device/edit/32)sceneNumber: 1 keyAttributes: 4

[dev:32](http://192.168.1.148/logs#dev32)2020-12-01 02:53:27.332 am [debug](http://192.168.1.148/device/edit/32)SupervisionGet: SupervisionGet(statusUpdates:false, reserved:0, sessionID:43, commandLength:5, commandClassIdentifier:91, commandIdentifier:3, commandByte:[91, 132, 1])

[dev:32](http://192.168.1.148/logs#dev32)2020-12-01 02:53:27.327 am [debug](http://192.168.1.148/device/edit/32)parse() for: zw device: 31, command: 6C01, payload: 2B 05 5B 03 5B 84 01 , isMulticast: false

(Seriously, I'm just gonna wire one of these up in a box with a plug and send it to you)

I did a quick search, and found an example with secure() instead of command() in that call, so I tried that.

Seems to have alleviated the error, but then this is the logging (top is latest log entry)...

[dev:32](http://192.168.1.148/logs#dev32)2020-12-01 03:08:34.282 am [debug](http://192.168.1.148/device/edit/32)Parse returned null for command null

[dev:32](http://192.168.1.148/logs#dev32)2020-12-01 03:08:34.241 am [debug](http://192.168.1.148/device/edit/32)sceneNumber: 1 keyAttributes: 4

[dev:32](http://192.168.1.148/logs#dev32)2020-12-01 03:08:34.225 am [debug](http://192.168.1.148/device/edit/32)SupervisionGet: SupervisionGet(statusUpdates:false, reserved:0, sessionID:45, commandLength:5, commandClassIdentifier:91, commandIdentifier:3, commandByte:[93, 132, 1])

[dev:32](http://192.168.1.148/logs#dev32)2020-12-01 03:08:34.171 am [debug](http://192.168.1.148/device/edit/32)parse() for: zw device: 31, command: 6C01, payload: 2D 05 5B 03 5D 84 01 , isMulticast: false

Not sure if that top entry means things worked or not. Doesn't seem like Webcore responded.

OK, sorry. The "secure" seems to have fixed it. I am not sure why that second parse() is called with nulls, but I added some debugging and when I tap 3x this is definitely called...

def tapUp3Response(String buttonType) {
    sendEvent(name: "status" , value: "Tap ▲▲▲")
	[name: "pushed", value: 5, descriptionText: "$device.displayName Tap-Up-3 (button 5) pushed", 
    isStateChange: true, type: "$buttonType"]
}

Of course, I am still seeing a problem. When I set and click this "push" tile in the device page, there are no log entries, but the state changes to the correct taps AND Webcore receives and processes the event.

HOWEVER, when I click the button physically, I see the logs but Webcore does not see the event.

Messing around a bit, it doesn't seem to be affected by $buttonType. So I am thinking that the physical press runs in a different context than the digital press? And so the event is not being captured by Webcore.

Let me know if you have an idea why that might be, otherwise I will be taking this over to the Webcore people.

I'll run it through a full test tomorrow and let you know how things look.

Thank you so much!

Thanks for figuring that out! I indeed used the wrong name for the name of that wrapper method (I've been editing drivers that use both of these names recently and slipped here). For anyone looking for an edited version, this is what I'd use:

(And note that if the status LEDs aren't working for you, the first thing I'd try is switching to the "Device" driver before this and running "Delete All States.")

/**
 *  HomeSeer HS-WD200+
 *
 *  Original Copyright 2018 HomeSeer
 *
 *  Modified from the work by DarwinsDen device handler for the WD100 version 1.03
 *
 *
 *  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.
 *
 *	Author: HomeSeer
 *	Date: 12/2017
 *   Modified: 12/2020 by RMoRobert
 *
 *	Changelog:
 *
 * 1.0	Initial Version (HomeSeer)
 * 1.0  Adaped for Hubitat by RMoRobert
 *
 *
 *   Button Mappings:
 *
 *   ACTION          BUTTON#    BUTTON ACTION
 *   Single-Tap Up     1        pushed
 *   Single-Tap Down   2        pushed
 *   Double-Tap Up     3        pushed
 *   Double-Tap Down   4        pushed
 *   Triple-Tap Up     5        pushed
 *   Triple-Tap Down   6        pushed
 *   4 taps up         7        pushed
 *   4 taps down       8       pushed
 *   5 taps up         9       pushed
 *   5 taps down       10       pushed
 *   Hold Up           1 	     held
 *   Hold Down         2 	     held
 *
 */

import groovy.transform.Field

@Field static final Map commandClassVersions = [
   0x20: 1,   //Basic
   0x26: 1,   //SwitchMultiLevel
   0x5B: 1,   //CentralScene
   0x70: 1    //Configuration
]

metadata {
	definition (name: "WD200+ Dimmer", namespace: "homeseer", author: "support@homeseer.com") {
		capability "Switch Level"
		capability "Actuator"
		capability "Indicator"
		capability "Switch"
		capability "Polling"
		capability "Refresh"
		capability "Sensor"
      capability "PushableButton"
      capability "HoldableButton"
      //capability "ReleasableButton"
      capability "Configuration"

      
      command "push", ["NUMBER"]
      command "hold", ["NUMBER"]
      //command "release", ["NUMBER"]

      command "setStatusLed", [[name:"LED*", type: "NUMBER", description: "LED number: 1-7 (bottom to top)"],
                               [name:"Color*", type: "NUMBER", description: "Color: 0=off, 1=red, 2=green, 3=blue, 4=magenta, 5=yellow, 6=cyan, 7=white"],
                               [name:"Blink", type: "NUMBER", description: "Blink: 0=no, 1=yes"]]
      command "setSwitchModeNormal"
      command "setSwitchModeStatus"
      command "setDefaultColor", [[name:"Color*", type: "NUMBER", description: "Color: 0=white, 1=red, 2=green, 3=blue, 4=magenta, 5=yellow, 6=cyan"]]
      
      fingerprint mfr: "000C", prod: "4447", model: "3036"
}
   preferences {      
      input "doubleTapToFullBright", "bool", title: "Double-tap up sets to full brightness",  defaultValue: false,  displayDuringSetup: true, required: false	       
      input "singleTapToFullBright", "bool", title: "Single-tap up sets to full brightness",  defaultValue: false,  displayDuringSetup: true, required: false	
      input "doubleTapDownToDim",    "bool", title: "Double-tap down sets to 25% level",      defaultValue: false,  displayDuringSetup: true, required: false	       
      input "reverseSwitch", "bool", title: "Reverse Switch",  defaultValue: false,  displayDuringSetup: true, required: false
      input "bottomled", "bool", title: "Bottom LED On if Load is Off",  defaultValue: false,  displayDuringSetup: true, required: false
      input "localcontrolramprate", "number", title: "Press Configure button after changing preferences\n\nLocal Ramp Rate: Duration (0-90) (1=1 sec) [default: 3]", defaultValue: 3,range: "0..90", required: false
      input "remotecontrolramprate", "number", title: "Remote Ramp Rate: duration (0-90) (1=1 sec) [default: 3]", defaultValue: 3, range: "0..90", required: false   
      input "color", "enum", title: "Default LED Color", options: ["White", "Red", "Green", "Blue", "Magenta", "Yellow", "Cyan"], description: "Select Color", required: false
      input "enableDebug", "bool", title: "Enable debug logging"
      input "enableInfo", "bool", title: "Enable descriptionText logging"
   }
}

def parse(String description) {
	def result = null
   if (enableDebug) log.debug "parse() for: $description"
    if (description != "updated") {
	    def cmd = zwave.parse(description, commandClassVersions)	
        if (cmd) {
		    result = zwaveEvent(cmd)
	    }
    }
    if (!result){
        if (enableDebug) log.debug "Parse returned ${result} for command ${cmd}"
    }
    else {
		if (enableDebug) log.debug "Parse returned ${result}"
    }   
	return result
}

String secure(String cmd){
   return zwaveSecureEncap(cmd)
}

String secure(hubitat.zwave.Command cmd){
   return zwaveSecureEncap(cmd)
}

def zwaveEvent(hubitat.zwave.commands.basicv1.BasicReport cmd) {
   dimmerEvents(cmd)
}

def zwaveEvent(hubitat.zwave.commands.basicv1.BasicSet cmd) {
	 dimmerEvents(cmd)
}

def zwaveEvent(hubitat.zwave.commands.switchmultilevelv1.SwitchMultilevelReport cmd) {
   dimmerEvents(cmd) 
}

def zwaveEvent(hubitat.zwave.commands.switchmultilevelv1.SwitchMultilevelSet cmd) {
	dimmerEvents(cmd)
}

private dimmerEvents(hubitat.zwave.Command cmd) {
	def value = (cmd.value ? "on" : "off")
	def result = [createEvent(name: "switch", value: value)]
   if (state.lastLevel != cmd.value && enableInfo) log.info "$device.displayName level is ${cmd.value}%"
   if (value != device.currentValue("switch") && enableInfo) log.info "$device.displayName switch is ${value}" 
   state.lastLevel = cmd.value
	if (cmd.value && cmd.value <= 100) {
		result << createEvent(name: "level", value: cmd.value, unit: "%")   
	}
	return result
}

def zwaveEvent(hubitat.zwave.commands.configurationv1.ConfigurationReport cmd) {
	if (enableDebug) log.debug "ConfigurationReport $cmd"
	def value = "when off"
	if (cmd.configurationValue[0] == 1) {value = "when on"}
	if (cmd.configurationValue[0] == 2) {value = "never"}
	createEvent([name: "indicatorStatus", value: value])
}

def zwaveEvent(hubitat.zwave.commands.hailv1.Hail cmd) {
	createEvent([name: "hail", value: "hail", descriptionText: "Switch button was pressed", displayed: false])
}

def zwaveEvent(hubitat.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {
	if (enableDebug) log.debug "manufacturerId:   ${cmd.manufacturerId}"
	if (enableDebug) log.debug "manufacturerName: ${cmd.manufacturerName}"
    state.manufacturer=cmd.manufacturerName
	if (enableDebug) log.debug "productId:        ${cmd.productId}"
	if (enableDebug) log.debug "productTypeId:    ${cmd.productTypeId}"
	def msr = String.format("%04X-%04X-%04X", cmd.manufacturerId, cmd.productTypeId, cmd.productId)
	updateDataValue("MSR", msr)	
    setFirmwareVersion()
    createEvent([descriptionText: "$device.displayName MSR: $msr", isStateChange: false])
}

def zwaveEvent(hubitat.zwave.commands.versionv1.VersionReport cmd) {	
    //updateDataValue("applicationVersion", "${cmd.applicationVersion}")
    if (enableDebug) log.debug ("received Version Report")
    if (enableDebug) log.debug "applicationVersion:      ${cmd.applicationVersion}"
    if (enableDebug) log.debug "applicationSubVersion:   ${cmd.applicationSubVersion}"
    state.firmwareVersion=cmd.applicationVersion+'.'+cmd.applicationSubVersion
    if (enableDebug) log.debug "zWaveLibraryType:        ${cmd.zWaveLibraryType}"
    if (enableDebug) log.debug "zWaveProtocolVersion:    ${cmd.zWaveProtocolVersion}"
    if (enableDebug) log.debug "zWaveProtocolSubVersion: ${cmd.zWaveProtocolSubVersion}"
    setFirmwareVersion()
    createEvent([descriptionText: "Firmware V"+state.firmwareVersion, isStateChange: false])
}

def zwaveEvent(hubitat.zwave.commands.firmwareupdatemdv2.FirmwareMdReport cmd) { 
    if (enableDebug) log.debug ("received Firmware Report")
    if (enableDebug) log.debug "checksum:       ${cmd.checksum}"
    if (enableDebug) log.debug "firmwareId:     ${cmd.firmwareId}"
    if (enableDebug) log.debug "manufacturerId: ${cmd.manufacturerId}"
    [:]
}

def zwaveEvent(hubitat.zwave.commands.switchmultilevelv1.SwitchMultilevelStopLevelChange cmd) {
   if (enableInfo) log.info "$device.displayName level is on"
	[createEvent(name:"switch", value:"on"), response(secure(zwave.switchMultilevelV1.switchMultilevelGet()))]
}

def zwaveEvent(hubitat.zwave.Command cmd) {
	// Handles all Z-Wave commands we aren't interested in
   if (enableDebug) log.debug "skip: $cmd"
	return []
}

def zwaveEvent(hubitat.zwave.commands.supervisionv1.SupervisionGet cmd) {
   if (enableDebug) log.debug "SupervisionGet: $cmd"
  hubitat.zwave.Command encapCmd = cmd.encapsulatedCommand(commandClassVersions)
  sendHubCommand(new hubitat.device.HubAction(secure(zwave.supervisionV1.supervisionReport(sessionID: cmd.sessionID, reserved: 0, moreStatusUpdates: false, status: 0xFF, duration: 0)), hubitat.device.Protocol.ZWAVE))
  if (encapCmd) {
     return zwaveEvent(encapCmd)
  }
}

def on() {
	//sendEvent(tapUp1Response("digital"))
	delayBetween([
			secure(zwave.basicV1.basicSet(value: 0xFF)),
			secure(zwave.switchMultilevelV1.switchMultilevelGet())
	], 5000)
}

def off() {
	//sendEvent(tapDown1Response("digital"))
	delayBetween([
			secure(zwave.basicV1.basicSet(value: 0x00)),
			secure(zwave.switchMultilevelV1.switchMultilevelGet())
	],5000)
}

List<String> setLevel(value) {
	if (enableDebug) log.debug "setLevel >> value: $value"
	def valueaux = value as Integer
	def level = Math.max(Math.min(valueaux, 99), 0)
   if (level <= 0) {      
      return delayBetween([
            seucre(zwave.basicV1.basicSet(value: 0x00)),
            secure(zwave.switchMultilevelV1.switchMultilevelGet())
      ],5000)
   }
   else {
      def result = []
      result += response(secure(zwave.basicV1.basicSet(value: level)))
      result += response(secure("delay 5000"))
      result += response(secure(zwave.switchMultilevelV1.switchMultilevelGet()))
      result += response(secure("delay 5000"))
      result += response(secure(zwave.switchMultilevelV1.switchMultilevelGet()))
      return result
   }
}

   List<String> setLevel(value, duration) {
	if (enableDebug) log.debug "setLevel >> value: $value, duration: $duration"
  def dimmingDuration = duration < 128 ? duration : 128 + Math.round(duration / 60)
  return [
     secure(zwave.switchMultilevelV2.switchMultilevelSet(value: value < 100 ? value : 99, dimmingDuration: dimmingDuration))
  ]
   }

/*
 *  Set dimmer to status mode, then set the color of the individual LED
 *
 *  led = 1-7
 *  color = 0=0ff
 *          1=red
 *          2=green
 *          3=blue
 *          4=magenta
 *          5=yellow
 *          6=cyan
 *          7=white
 */
def setStatusLed(led, color, blink) {
   if (enableDebug) log.debug "setStatusLED >> led: $led, color: $color, blink: $blink"
    List cmds= []
    
    if(state.statusled1==null) {    	
    	   state.statusled1=0
        state.statusled2=0
        state.statusled3=0
        state.statusled4=0
        state.statusled5=0
        state.statusled6=0
        state.statusled7=0
        state.blinkval=0
    }
    
    state."statusled{$led}" = color
   
    if(state.statusled1==0 && state.statusled2==0 && state.statusled3==0 && state.statusled4==0 && state.statusled5==0 && state.statusled6==0 && state.statusled7==0)
    {
    	// no LEDS are set, put back to NORMAL mode
        cmds << secure(zwave.configurationV2.configurationSet(scaledConfigurationValue: 0, parameterNumber: 13, size: 1))
    }
    else
    {
    	// at least one LED is set, put to status mode
        cmds << secure(zwave.configurationV2.configurationSet(scaledConfigurationValue: 1, parameterNumber: 13, size: 1))
        // set the LED to color
        cmds << secure(zwave.configurationV2.configurationSet(scaledConfigurationValue: color.toInteger(), parameterNumber: (led.toInteger() + 20), size: 1))
        // check if LED should be blinking
        Integer blinkval = state.blinkval ?: 0
        if(blink)
        {
            switch(led) {
            	case 1:
                	blinkval = blinkval | 0x1
                    break
                case 2:
                	blinkval = blinkval | 0x2
                    break
                case 3:
                	blinkval = blinkval | 0x4
                    break
                case 4:
                	blinkval = blinkval | 0x8
                    break
                case 5:
                	blinkval = blinkval | 0x10
                    break
                case 6:
                	blinkval = blinkval | 0x20
                    break
                case 7:
                	blinkval = blinkval | 0x40
                    break
            }
        	cmds << secure(zwave.configurationV2.configurationSet(scaledConfigurationValue: blinkval, parameterNumber: 31, size: 1))
            // set blink speed, also enables blink, 1=100ms blink frequency
            cmds << secure(zwave.configurationV2.configurationSet(scaledConfigurationValue: 5, parameterNumber: 30, size: 1))
            state.blinkval = blinkval
        }
        else {
        	switch(led.toInteger()) {
            	case 1:
                	blinkval = blinkval & 0xFE
                    break
                case 2:
                	blinkval = blinkval & 0xFD
                    break
                case 3:
                	blinkval = blinkval & 0xFB
                    break
                case 4:
                	blinkval = blinkval & 0xF7
                    break
                case 5:
                	blinkval = blinkval & 0xEF
                    break
                case 6:
                	blinkval = blinkval & 0xDF
                    break
                case 7:
                	blinkval = blinkval & 0xBF
                    break
            }
            cmds << secure(zwave.configurationV2.configurationSet(scaledConfigurationValue: blinkval, parameterNumber: 31, size: 1))
            state.blinkval = blinkval
        }
    }
 	return delayBetween(cmds, 500)
}

/*
 * Set Dimmer to Normal dimming mode (exit status mode)
 *
 */
def setSwitchModeNormal() {
	def cmds= []
    cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [0], parameterNumber: 13, size: 1))
    delayBetween(cmds, 500)
}

/*
 * Set Dimmer to Status mode (exit normal mode)
 *
 */
def setSwitchModeStatus() {
	def cmds= []
    cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [1], parameterNumber: 13, size: 1))
    delayBetween(cmds, 500)
}

/*
 * Set the color of the LEDS for normal dimming mode, shows the current dim level
 */
def setDefaultColor(color) {
	def cmds= []
    cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [color], parameterNumber: 14, size: 1))
    delayBetween(cmds, 500)
}


def poll() {
	secure(zwave.switchMultilevelV1.switchMultilevelGet())
}

def refresh() {
	if (enableDebug) log.debug "refresh() called"
  configure()
}

def zwaveEvent(hubitat.zwave.commands.centralscenev1.CentralSceneNotification cmd) {
    if (enableDebug) log.debug("sceneNumber: ${cmd.sceneNumber} keyAttributes: ${cmd.keyAttributes}")
    def result = []
    
    switch (cmd.sceneNumber) {
      case 1:
          // Up
          switch (cmd.keyAttributes) {
              case 0:
                   // Press Once
                  result += createEvent(tapUp1Response("physical"))  
                  result += createEvent([name: "switch", value: "on", type: "physical"])
       
                  if (singleTapToFullBright)
                  {
                     result += setLevel(99)
                     result += response(secure("delay 5000"))
                     result += response(secure(zwave.switchMultilevelV1.switchMultilevelGet()))
                  } 
                  break
              case 1:
                  result=createEvent([name: "switch", value: "on", type: "physical"])
                  break
              case 2:
                  // Hold
                  result += createEvent(holdUpResponse("physical"))  
                  result += createEvent([name: "switch", value: "on", type: "physical"])    
                  break
              case 3: 
                  // 2 Times
                  result +=createEvent(tapUp2Response("physical"))
                  if (doubleTapToFullBright)
                  {
                     result += setLevel(99)
                     result += response(secure("delay 5000"))
                     result += response(secure(zwave.switchMultilevelV1.switchMultilevelGet()))
                  }                    
                  break
              case 4:
                  // 3 times
                  result=createEvent(tapUp3Response("physical"))
                  break
              case 5:
                  // 4 times
                  result=createEvent(tapUp4Response("physical"))
                  break
              case 6:
                  // 5 times
                  result=createEvent(tapUp5Response("physical"))
                  break
              default:
                  if (enableDebug) log.debug ("unexpected up press keyAttribute: $cmd.keyAttributes")
          }
          break
          
      case 2:
          // Down
          switch (cmd.keyAttributes) {
              case 0:
                  // Press Once
                  result += createEvent(tapDown1Response("physical"))
                  result += createEvent([name: "switch", value: "off", type: "physical"]) 
                  break
              case 1:
                  result=createEvent([name: "switch", value: "off", type: "physical"])
                  break
              case 2:
                  // Hold
                  result += createEvent(holdDownResponse("physical"))
                  result += createEvent([name: "switch", value: "off", type: "physical"]) 
                  break
              case 3: 
                  // 2 Times
                  result+=createEvent(tapDown2Response("physical"))
                  if (doubleTapDownToDim)
                  {
                     result += setLevel(25)
                     result += response(secure("delay 5000"))
                     result += response(secure(zwave.switchMultilevelV1.switchMultilevelGet()))
                  }  
                  break
              case 4:
                  // 3 Times
                  result=createEvent(tapDown3Response("physical"))
                  break
              case 5:
                  // 4 Times
                  result=createEvent(tapDown4Response("physical"))
                  break
              case 6:
                  // 5 Times
                  result=createEvent(tapDown5Response("physical"))
                  break
              default:
                  if (enableDebug) log.debug ("unexpected down press keyAttribute: $cmd.keyAttributes")
           } 
           break
           
      default:
           // unexpected case
           if (enableDebug)  log.debug ("unexpected scene: $cmd.sceneNumber")
   }  
   return result
}

def tapUp1Response(String buttonType) {
   sendEvent(name: "status" , value: "Tap ▲")
	[name: "pushed", value: 1, descriptionText: "$device.displayName Tap-Up-1 (button 1) pushed", 
       isStateChange: true, type: "$buttonType"]
}

def tapDown1Response(String buttonType) {
    sendEvent(name: "status" , value: "Tap ▼")
	[name: "pushed", value: 2, descriptionText: "$device.displayName Tap-Down-1 (button 2) pushed", 
      isStateChange: true, type: "$buttonType"]
}

def tapUp2Response(String buttonType) {
    sendEvent(name: "status" , value: "Tap ▲▲")
	[name: "pushed", value: 3, descriptionText: "$device.displayName Tap-Up-2 (button 3) pushed", 
       isStateChange: true, type: "$buttonType"]
}

def tapDown2Response(String buttonType) {
    sendEvent(name: "status" , value: "Tap ▼▼")
	[name: "pushed", value: 4, descriptionText: "$device.displayName Tap-Down-2 (button 4) pushed", 
      isStateChange: true, type: "$buttonType"]
}

def tapUp3Response(String buttonType) {
    sendEvent(name: "status" , value: "Tap ▲▲▲")
	[name: "pushed", value: 5, descriptionText: "$device.displayName Tap-Up-3 (button 5) pushed", 
    isStateChange: true, type: "$buttonType"]
}

def tapUp4Response(String buttonType) {
    sendEvent(name: "status" , value: "Tap ▲▲▲▲")
	[name: "pushed", value: 7, descriptionText: "$device.displayName Tap-Up-4 (button 7) pushed", 
    isStateChange: true, type: "$buttonType"]
}

def tapUp5Response(String buttonType) {
    sendEvent(name: "status" , value: "Tap ▲▲▲▲▲")
	[name: "pushed", value: 9, descriptionText: "$device.displayName Tap-Up-5 (button 9) pushed", 
    isStateChange: true, type: "$buttonType"]
}

def tapDown3Response(String buttonType) {
    sendEvent(name: "status" , value: "Tap ▼▼▼")
	[name: "pushed", value: 6, descriptionText: "$device.displayName Tap-Down-3 (button 6) pushed", 
    isStateChange: true, type: "$buttonType"]
}

def tapDown4Response(String buttonType) {
    sendEvent(name: "status" , value: "Tap ▼▼▼▼")
	[name: "pushed", value: 8, descriptionText: "$device.displayName Tap-Down-3 (button 8) pushed", 
    isStateChange: true, type: "$buttonType"]
}

def tapDown5Response(String buttonType) {
    sendEvent(name: "status" , value: "Tap ▼▼▼▼▼")
	[name: "pushed", value: 10, descriptionText: "$device.displayName Tap-Down-3 (button 10) pushed", 
    isStateChange: true, type: "$buttonType"]
}

def holdUpResponse(String buttonType) {
    sendEvent(name: "status" , value: "Hold ▲")
	[name: "held", value: 1, descriptionText: "$device.displayName Hold-Up (button 1) held", 
    isStateChange: true, type: "$buttonType"]
}

def holdDownResponse(String buttonType) {
    sendEvent(name: "status" , value: "Hold ▼")
	[name: "held", value: 2, descriptionText: "$device.displayName Hold-Down (button 2) held", 
    isStateChange: true, type: "$buttonType"]
}

def push(Number button) {
   switch (button as Integer) {
      case 1:
         sendEvent(tapUp1Response("digital"))
         break
      case 2:
         sendEvent(tapDown1Response("digital"))
         break
      case 3:
         sendEvent(tapUp2Response("digital"))
         break
      case 4:
         sendEvent(tapDown2Response("digital"))
         break
      case 5:
         sendEvent(tapUp3Response("digital"))
         break
      case 6:
         sendEvent(tapDown3Response("digital"))
         break
      case 7:
         sendEvent(tapUp4Response("digital"))
         break
      case 8:
         sendEvent(tapDown4Response("digital"))
         break
      case 9:
         sendEvent(tapUp5Response("digital"))
         break
      case 10:
         sendEvent(tapDown5Response("digital"))
         break
      default:
         log.warn "Invalid button number in push(): $button"
   }
}

def hold(Number button) {
   if (button as Integer == 1) {
	   sendEvent(holdUpResponse("digital"))
   }
   else if (button as Integer == 2) {
      sendEvent(holdDownResponse("digital"))
   }
   else {
      log.warn "Invalid button in hold(): $button"
   }
}
/*
def release(Number button) {
   if (button as Integer == 1) {
	   sendEvent(releaseUpResponse("digital"))
   }
   else if (button as Integer == 2) {
      sendEvent(releaseDownResponse("digital"))
   }
   else {
      log.warn "Invalid button in release(): $button"
   }
}
*/


def setFirmwareVersion() {
   def versionInfo = ''
   if (state.manufacturer)
   {
      versionInfo=state.manufacturer+' '
   }
   if (state.firmwareVersion)
   {
      versionInfo=versionInfo+"Firmware V"+state.firmwareVersion
   }
   else 
   {
     versionInfo=versionInfo+"Firmware unknown"
   }   
   sendEvent(name: "firmwareVersion",  value: versionInfo, isStateChange: true, displayed: false)
}

def configure() {
   log.trace ("configure() called")
 
   sendEvent(name: "numberOfButtons", value: 10)
   def commands = []
   commands << setDimRatePrefs()
   commands << secure(zwave.switchMultilevelV1.switchMultilevelGet())
   commands << secure(zwave.manufacturerSpecificV1.manufacturerSpecificGet())
   commands << secure(zwave.versionV1.versionGet())
   return delayBetween(commands,500)
}

def setDimRatePrefs() 
{
   if (enableDebug) log.trace ("set prefs")
   def cmds = []

	if (color)
    {
        switch (color) {
        	case "White":
            	cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [0], parameterNumber: 14, size: 1))
                break
      		case "Red":
            	cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [1], parameterNumber: 14, size: 1))
                break
            case "Green":
            	cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [2], parameterNumber: 14, size: 1))
                break
            case "Blue":
            	cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [3], parameterNumber: 14, size: 1))
                break
            case "Magenta":
            	cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [4], parameterNumber: 14, size: 1))
                break
            case "Yellow":
            	cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [5], parameterNumber: 14, size: 1))
                break
            case "Cyan":
            	cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [6], parameterNumber: 14, size: 1))
                break
            
            
      	}
    }    
   
   if(localcontrolramprate != null) {
   		//if (enableDebug) log.debug localcontrolramprate
   		def localcontrolramprate = Math.max(Math.min(localcontrolramprate, 90), 0)
   		cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [localcontrolramprate], parameterNumber: 12, size: 1))
   }
   
   if(remotecontrolramprate != null) {
   		if (enableDebug) log.debug remotecontrolramprate
   		def remotecontrolramprate = Math.max(Math.min(remotecontrolramprate, 90), 0)
   		cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [remotecontrolramprate], parameterNumber: 11, size: 1))
   }
   
   if (reverseSwitch)
   {
       cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [1], parameterNumber: 4, size: 1))
   }
   else
   {
      cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [0], parameterNumber: 4, size: 1))
   }
   
   if (bottomled)
   {
       cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [0], parameterNumber: 3, size: 1))
   }
   else
   {
      cmds << secure(zwave.configurationV2.configurationSet(configurationValue: [1], parameterNumber: 3, size: 1))
   }
   
   //Enable the following configuration gets to verify configuration in the logs
   //cmds << secure(zwave.configurationV1.configurationGet(parameterNumber: 7))
   //cmds << secure(zwave.configurationV1.configurationGet(parameterNumber: 8))
   //cmds << secure(zwave.configurationV1.configurationGet(parameterNumber: 9))
   //cmds << secure(zwave.configurationV1.configurationGet(parameterNumber: 10))
   
   return cmds
}
 
def updated()
{
   def cmds= []
   cmds << setDimRatePrefs
   delayBetween(cmds, 500)
}
3 Likes

Very cool, thanks.

Do you have any idea why it's not triggering webcore? I posted in their forums, but no response yet.

I am about to light up Rule Machine to see how it does.

I'm not sure, but if you get an event on the Hubitat side (check the "Events" button on the device page in Hubitat to be sure rather than going by logs), it should theoretically be usable by an app. WebCoRE, as you probably know, was originally written for SmartThings, and Hubitat's button model is a bit different, but the current HE fork has been adapted for that. I don't have any of the HomeSeer devices, but a quick test with a virtual button worked for me:

webCoRE piston screenshot

Testing this, Rule Machine also fails to capture a physical tap, but triggers with a digital push.

I added a log line here...

def tapUp3Response(String buttonType) {
    if (enableDebug) log.debug "Tap ▲▲▲"
    sendEvent(name: "status" , value: "Tap ▲▲▲")
	[name: "pushed", value: 5, descriptionText: "$device.displayName Tap-Up-3 (button 5) pushed", 
    isStateChange: true, type: "$buttonType"]
}

Here is the log if I use the digital button to push 5:

[dev:32][...][debug] Tap ▲▲▲

Here's the log if I press it physically (latest at top):

[dev:32][...][debug] Parse returned null for command null

[dev:32][...][debug] Tap ▲▲▲

[dev:32][...][debug] sceneNumber: 1 keyAttributes: 4

[dev:32][...][debug] SupervisionGet: SupervisionGet(statusUpdates:false, reserved:0, sessionID:55, commandLength:5, commandClassIdentifier:91, commandIdentifier:3, commandByte:[103, 132, 1])

[dev:32][...][debug] parse() for: zw device: 31, command: 6C01, payload: 37 05 5B 03 67 84 01 , isMulticast: false

So it's clearly handling the ZWave event and invoking the same function to send the "pushed value 5 event.

Differences:

  1. Button Type; but I have recoded this to send either button type and neither rule machine or Webcore cares, they still only process the digital press

  2. The physical press seems to generate a second null event?

So it seems to me that this is probably not a webcore issue.

Lastly, if I insert the debug statement AFTER that last line in the squate bracket above, I get this error:

[dev:32](http://192.168.1.148/logs#dev32)2020-12-01 03:14:36.779 pm [error](http://192.168.1.148/device/edit/32)java.lang.NullPointerException: Cannot get property 'name' on null object on line 599 (push)

I am not familiar with Groovy and Java that much, what is that bracket statement and why can't I insert code after it in that function? Is it possible that the second parse() call we see in the physical press is mucking with the event?

OK, I just did a physical 3-tap and then a "Push 5" from the device page...

The bottom entry was the single status event generated by the three taps.

The top two entries are an identical status PLUS a Pushed 5 event.

So it appears that the Pushed 5 event is not being generated when this is a physical tap.

Name Value Unit Description Text Source Type Date
pushed 5 Front Lights Tap-Up-3 (button 5) pushed DEVICE digital 2020-12-01 03:19:29.592 PM EST
status Tap ▲▲▲ DEVICE 2020-12-01 03:19:29.591 PM EST
status Tap ▲▲▲ DEVICE 2020-12-01 03:18:43.682 PM EST

(Aside: I can't get Webcore to trigger on a status event, but that seems like a webcore question)