Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 34 additions & 12 deletions devicetypes/smartthings/aeotec-wallmote.src/aeotec-wallmote.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ metadata {

fingerprint mfr: "0086", model: "0082", deviceJoinName: "Aeotec Wallmote Quad", mnmn: "SmartThings", vid: "generic-4-button"
fingerprint mfr: "0086", model: "0081", deviceJoinName: "Aeotec Wallmote", mnmn: "SmartThings", vid: "generic-2-button"
fingerprint mfr: "0060", model: "0003", deviceJoinName: "Everspring Wall Switch", mnmn: "SmartThings", vid: "generic-2-button"
}

tiles(scale: 2) {
Expand All @@ -44,14 +45,14 @@ metadata {
}

def getNumberOfButtons() {
def modelToButtons = ["0082" : 4, "0081": 2]
def modelToButtons = ["0082" : 4, "0081": 2, "0003": 2]
return modelToButtons[zwaveInfo.model] ?: 1
}

def installed() {
createChildDevices()
sendEvent(name: "numberOfButtons", value: numberOfButtons, displayed: false)
sendEvent(name: "supportedButtonValues", value: ["pushed", "held"].encodeAsJson(), displayed: false)
sendEvent(name: "supportedButtonValues", value: supportedButtonValues.encodeAsJson(), displayed: false)
sendEvent(name: "button", value: "pushed", data: [buttonNumber: 1], displayed: false)
}

Expand Down Expand Up @@ -90,14 +91,9 @@ def parse(String description) {

def zwaveEvent(physicalgraph.zwave.commands.centralscenev1.CentralSceneNotification cmd) {
def button = cmd.sceneNumber
def value
// 0 = pushed, 1 = released, 2 = held down
if (cmd.keyAttributes != 2) {
value = cmd.keyAttributes == 1 ? "held" : "pushed"
} else {
// we can't do anything with the held down event yet
return []
}

def value = buttonAttributesMap[(int)cmd.keyAttributes]

def child = getChildDevice(button)
child?.sendEvent(name: "button", value: value, data: [buttonNumber: 1], descriptionText: "$child.displayName was $value", isStateChange: true)
createEvent(name: "button", value: value, data: [buttonNumber: button], descriptionText: "$device.displayName button $button was $value", isStateChange: true)
Expand Down Expand Up @@ -149,7 +145,7 @@ def createChildDevices() {
child = addChildDevice("Child Button", "${device.deviceNetworkId}:${i}", device.hubId,
[completedSetup: true, label: "${device.displayName} button ${i}",
isComponent: true, componentName: "button$i", componentLabel: "Button $i"])
child.sendEvent(name: "supportedButtonValues", value: ["pushed", "held"].encodeAsJson(), displayed: false)
child.sendEvent(name: "supportedButtonValues", value: supportedButtonValues.encodeAsJson(), displayed: false)
child.sendEvent(name: "button", value: "pushed", data: [buttonNumber: 1], descriptionText: "$child.displayName was pushed", isStateChange: true, displayed: false)
}
}
Expand All @@ -170,4 +166,30 @@ def getChildDevice(button) {
log.error "Child device $childDni not found"
}
return child
}
}

private getSupportedButtonValues() {
if (isEverspring()) {
return ["pushed", "held", "double"]
} else {
return ["pushed", "held"]
}
}

private getButtonAttributesMap() {
if (isEverspring()) {[
0: "pushed",
2: "held",
3: "double"
]}
else {[
0: "pushed",
1: "held"
]}
}

private isEverspring() {
zwaveInfo.model.equals("0003")
}