2 * Virtual Buttons for Multi-Button Controllers (ex. Minimote or ZWN-SC7)
5 * Date Created: 2015-05-13
9 name: "Virtual Buttons",
10 namespace: "com.obycode",
12 description: "Create virtual single button devices for each button of your multi-button device (ex. Minimote or ZWN-SC7)",
13 category: "Convenience",
14 iconUrl: "http://cdn.device-icons.smartthings.com/unknown/zwave/remote-controller.png",
15 iconX2Url: "http://cdn.device-icons.smartthings.com/unknown/zwave/remote-controller@2x.png"
19 section ("Select your button controller: ") {
20 input "buttonDevice", "capability.button", title: "Which?", multiple: false, required: true
32 def numButtons = buttonDevice.currentValue("numButtons").toInteger()
33 log.info "Creating $numButtons virtual buttons"
34 // Create the virtual buttons
35 (1..numButtons).each {
36 def d = addChildDevice("com.obycode", "Virtual Button", buttonDevice.id + ":" + it.toString(), null, [label:buttonDevice.displayName + " " + it.toString(), name:"Virtual Button", completedSetup: true])
39 // Subscribe to the button events
40 subscribe(buttonDevice, "button", buttonEvent)
45 def delete = getChildDevices()
47 deleteChildDevice(it.deviceNetworkId)
51 def buttonEvent(evt) {
52 log.debug "buttonEvent: $evt.name $evt.value ($evt.data)"
53 def buttonNumber = evt.jsonData.buttonNumber
55 def buttonId = buttonDevice.id + ":" + buttonNumber
56 def children = getChildDevices()
57 def childButton = children.find{ d -> d.deviceNetworkId == buttonId }
61 log.debug "pushing the virtual button"
65 log.debug "holding the virtual button"
69 log.debug "releasing the virtual button"
73 log.debug "Unknown event: $evt.value"