DVCSMP-2211 - Update Button Number and Holdable capability (#1458)

This commit is contained in:
Juan Pablo Risso
2016-11-11 16:10:44 -05:00
committed by GitHub
parent 7978f45996
commit 1db5f75ec5
5 changed files with 43 additions and 24 deletions

View File

@@ -15,6 +15,7 @@ metadata {
definition (name: "Aeon Key Fob", namespace: "smartthings", author: "SmartThings") { definition (name: "Aeon Key Fob", namespace: "smartthings", author: "SmartThings") {
capability "Actuator" capability "Actuator"
capability "Button" capability "Button"
capability "Holdable Button"
capability "Configuration" capability "Configuration"
capability "Sensor" capability "Sensor"
capability "Battery" capability "Battery"
@@ -118,3 +119,7 @@ def configure() {
log.debug("Sending configuration: $cmd") log.debug("Sending configuration: $cmd")
return cmd return cmd
} }
def updated() {
sendEvent(name: "numberOfButtons", value: 4)
}

View File

@@ -15,6 +15,7 @@ metadata {
definition (name: "Aeon Minimote", namespace: "smartthings", author: "SmartThings") { definition (name: "Aeon Minimote", namespace: "smartthings", author: "SmartThings") {
capability "Actuator" capability "Actuator"
capability "Button" capability "Button"
capability "Holdable Button"
capability "Configuration" capability "Configuration"
capability "Sensor" capability "Sensor"
@@ -107,3 +108,7 @@ def configure() {
log.debug("Sending configuration: $cmds") log.debug("Sending configuration: $cmds")
return cmds return cmds
} }
def updated() {
sendEvent(name: "numberOfButtons", value: 4)
}

View File

@@ -16,7 +16,7 @@ metadata {
capability "Switch" capability "Switch"
capability "Switch Level" capability "Switch Level"
capability "Button" capability "Button"
capability "Actuator" capability "Actuator"
//fingerprint deviceId: "0x1200", inClusters: "0x77 0x86 0x75 0x73 0x85 0x72 0xEF", outClusters: "0x26" //fingerprint deviceId: "0x1200", inClusters: "0x77 0x86 0x75 0x73 0x85 0x72 0xEF", outClusters: "0x26"
} }
@@ -74,20 +74,20 @@ def off() {
} }
def levelup() { def levelup() {
def curlevel = device.currentValue('level') as Integer def curlevel = device.currentValue('level') as Integer
if (curlevel <= 90) if (curlevel <= 90)
setLevel(curlevel + 10); setLevel(curlevel + 10);
} }
def leveldown() { def leveldown() {
def curlevel = device.currentValue('level') as Integer def curlevel = device.currentValue('level') as Integer
if (curlevel >= 10) if (curlevel >= 10)
setLevel(curlevel - 10) setLevel(curlevel - 10)
} }
def setLevel(value) { def setLevel(value) {
log.trace "setLevel($value)" log.trace "setLevel($value)"
sendEvent(name: "level", value: value) sendEvent(name: "level", value: value)
} }
def zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd) { def zwaveEvent(physicalgraph.zwave.commands.wakeupv1.WakeUpNotification cmd) {
@@ -106,11 +106,11 @@ def zwaveEvent(physicalgraph.zwave.commands.switchmultilevelv1.SwitchMultilevelS
if (cmd.upDown == true) { if (cmd.upDown == true) {
Integer buttonid = 2 Integer buttonid = 2
leveldown() leveldown()
checkbuttonEvent(buttonid) checkbuttonEvent(buttonid)
} else if (cmd.upDown == false) { } else if (cmd.upDown == false) {
Integer buttonid = 3 Integer buttonid = 3
levelup() levelup()
checkbuttonEvent(buttonid) checkbuttonEvent(buttonid)
} }
} }
@@ -140,12 +140,12 @@ def buttonEvent(button) {
def result = [] def result = []
if (button == 1) { if (button == 1) {
def mystate = device.currentValue('switch'); def mystate = device.currentValue('switch');
if (mystate == "on") if (mystate == "on")
off() off()
else else
on() on()
} }
updateState("currentButton", "$button") updateState("currentButton", "$button")
// update the device state, recording the button press // update the device state, recording the button press
result << createEvent(name: "button", value: "pushed", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was pushed", isStateChange: true) result << createEvent(name: "button", value: "pushed", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was pushed", isStateChange: true)
result result
@@ -182,3 +182,7 @@ def updateState(String name, String value) {
state[name] = value state[name] = value
device.updateDataValue(name, value) device.updateDataValue(name, value)
} }
def updated() {
sendEvent(name: "numberOfButtons", value: 3)
}

View File

@@ -15,9 +15,10 @@ metadata {
definition (name: "Simulated Minimote", namespace: "smartthings/testing", author: "SmartThings") { definition (name: "Simulated Minimote", namespace: "smartthings/testing", author: "SmartThings") {
capability "Actuator" capability "Actuator"
capability "Button" capability "Button"
capability "Holdable Button"
capability "Configuration" capability "Configuration"
capability "Sensor" capability "Sensor"
command "push1" command "push1"
command "push2" command "push2"
command "push3" command "push3"
@@ -45,42 +46,42 @@ metadata {
} }
standardTile("push1", "device.button", width: 1, height: 1, decoration: "flat") { standardTile("push1", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: "Push 1", backgroundColor: "#ffffff", action: "push1" state "default", label: "Push 1", backgroundColor: "#ffffff", action: "push1"
} }
standardTile("push2", "device.button", width: 1, height: 1, decoration: "flat") { standardTile("push2", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: "Push 2", backgroundColor: "#ffffff", action: "push2" state "default", label: "Push 2", backgroundColor: "#ffffff", action: "push2"
} }
standardTile("push3", "device.button", width: 1, height: 1, decoration: "flat") { standardTile("push3", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: "Push 3", backgroundColor: "#ffffff", action: "push3" state "default", label: "Push 3", backgroundColor: "#ffffff", action: "push3"
} }
standardTile("push4", "device.button", width: 1, height: 1, decoration: "flat") { standardTile("push4", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: "Push 4", backgroundColor: "#ffffff", action: "push4" state "default", label: "Push 4", backgroundColor: "#ffffff", action: "push4"
} }
standardTile("dummy1", "device.button", width: 1, height: 1, decoration: "flat") { standardTile("dummy1", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: " ", backgroundColor: "#ffffff", action: "push4" state "default", label: " ", backgroundColor: "#ffffff", action: "push4"
} }
standardTile("hold1", "device.button", width: 1, height: 1, decoration: "flat") { standardTile("hold1", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: "Hold 1", backgroundColor: "#ffffff", action: "hold1" state "default", label: "Hold 1", backgroundColor: "#ffffff", action: "hold1"
} }
standardTile("hold2", "device.button", width: 1, height: 1, decoration: "flat") { standardTile("hold2", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: "Hold 2", backgroundColor: "#ffffff", action: "hold2" state "default", label: "Hold 2", backgroundColor: "#ffffff", action: "hold2"
} }
standardTile("dummy2", "device.button", width: 1, height: 1, decoration: "flat") { standardTile("dummy2", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: " ", backgroundColor: "#ffffff", action: "push4" state "default", label: " ", backgroundColor: "#ffffff", action: "push4"
} }
standardTile("hold3", "device.button", width: 1, height: 1, decoration: "flat") { standardTile("hold3", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: "Hold 3", backgroundColor: "#ffffff", action: "hold3" state "default", label: "Hold 3", backgroundColor: "#ffffff", action: "hold3"
} }
standardTile("hold4", "device.button", width: 1, height: 1, decoration: "flat") { standardTile("hold4", "device.button", width: 1, height: 1, decoration: "flat") {
state "default", label: "Hold 4", backgroundColor: "#ffffff", action: "hold4" state "default", label: "Hold 4", backgroundColor: "#ffffff", action: "hold4"
} }
main "button" main "button"
details(["push1","push2","button","push3","push4","dummy1","hold1","hold2","dummy2","hold3","hold4"]) details(["push1","push2","button","push3","push4","dummy1","hold1","hold2","dummy2","hold3","hold4"])
} }
} }
def parse(String description) { def parse(String description) {
} }
def push1() { def push1() {
@@ -125,3 +126,6 @@ private hold(button) {
sendEvent(name: "button", value: "held", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was held", isStateChange: true) sendEvent(name: "button", value: "held", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was held", isStateChange: true)
} }
def updated() {
sendEvent(name: "numberOfButtons", value: 4)
}

View File

@@ -19,6 +19,7 @@ metadata {
capability "Actuator" capability "Actuator"
capability "Battery" capability "Battery"
capability "Button" capability "Button"
capability "Holdable Button"
capability "Configuration" capability "Configuration"
capability "Refresh" capability "Refresh"
capability "Sensor" capability "Sensor"