Skip to content

Commit

Permalink
Merge pull request #2 from stephack/patch-2
Browse files Browse the repository at this point in the history
Button 7 and 8 event changes - add button 7 & 8 events when on/off triggered remotely
  • Loading branch information
DarwinsDen authored Jun 25, 2017
2 parents 0aebffe + 43001f9 commit c82f054
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 17 deletions.
30 changes: 22 additions & 8 deletions devicetypes/darwinsden/wd100-dimmer.src/wd100-dimmer.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,15 @@ def zwaveEvent(physicalgraph.zwave.Command cmd) {
}

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

def off() {
sendEvent(tapDown1Response("digital"))
delayBetween([
zwave.basicV1.basicSet(value: 0x00).format(),
zwave.switchMultilevelV1.switchMultilevelGet().format()
Expand Down Expand Up @@ -307,10 +309,10 @@ def zwaveEvent(physicalgraph.zwave.commands.centralscenev1.CentralSceneNotificat
// Up
switch (cmd.keyAttributes) {
case 0:
// Press Once
result += createEvent(tapUp1Response("physical"))
result += response("delay 100")
result += createEvent([name: "switch", value: "on", type: "physical"])
sendEvent(name: "status" , value: "Tap ▲")
sendEvent(name: "button" , value: "pushed", data: [buttonNumber: "7"], descriptionText: "$device.displayName Tap-Up-1 (button 7) pressed",
isStateChange: true, type: "$buttonType")

if (singleTapToFullBright)
{
Expand Down Expand Up @@ -352,10 +354,10 @@ def zwaveEvent(physicalgraph.zwave.commands.centralscenev1.CentralSceneNotificat
// Down
switch (cmd.keyAttributes) {
case 0:
result=createEvent([name: "switch", value: "off", type: "physical"])
sendEvent(name: "status" , value: "Tap ▼")
sendEvent(name: "button" , value: "pushed", data: [buttonNumber: "8"], descriptionText: "$device.displayName Tap-Down-1 (button 8) pressed",
isStateChange: true, type: "$buttonType")
// Press Once
result += createEvent(tapDown1Response("physical"))
result += response("delay 100")
result += createEvent([name: "switch", value: "off", type: "physical"])
break
case 1:
result=createEvent([name: "switch", value: "off", type: "physical"])
Expand Down Expand Up @@ -391,6 +393,18 @@ def zwaveEvent(physicalgraph.zwave.commands.centralscenev1.CentralSceneNotificat
return result
}

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

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

def tapUp2Response(String buttonType) {
sendEvent(name: "status" , value: "Tap ▲▲")
[name: "button", value: "pushed", data: [buttonNumber: "1"], descriptionText: "$device.displayName Tap-Up-2 (button 1) pressed",
Expand Down Expand Up @@ -533,4 +547,4 @@ def updated()
def cmds= []
cmds << setDimRatePrefs
delayBetween(cmds, 500)
}
}
30 changes: 21 additions & 9 deletions devicetypes/darwinsden/ws100-switch.src/ws100-switch.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,15 @@ def zwaveEvent(physicalgraph.zwave.Command cmd) {
}

def on() {
sendEvent(tapUp1Response("digital"))
delayBetween([
zwave.basicV1.basicSet(value: 0xFF).format(),
zwave.switchBinaryV1.switchBinaryGet().format()
])
}

def off() {
sendEvent(tapDown1Response("digital"))
delayBetween([
zwave.basicV1.basicSet(value: 0x00).format(),
zwave.switchBinaryV1.switchBinaryGet().format()
Expand Down Expand Up @@ -273,10 +275,9 @@ def zwaveEvent(physicalgraph.zwave.commands.centralscenev1.CentralSceneNotificat
switch (cmd.keyAttributes) {
case 0:
// Press Once
result=createEvent([name: "switch", value: "on", type: "physical"])
sendEvent(name: "status" , value: "Tap ▲")
sendEvent(name: "button" , value: "pushed", data: [buttonNumber: "7"], descriptionText: "$device.displayName Tap-Up-1 (button 7) pressed",
isStateChange: true, type: "$buttonType")
result += createEvent(tapUp1Response("physical"))
result += response("delay 100")
result += createEvent([name: "switch", value: "on", type: "physical"])
break

case 1:
Expand Down Expand Up @@ -307,10 +308,9 @@ def zwaveEvent(physicalgraph.zwave.commands.centralscenev1.CentralSceneNotificat
switch (cmd.keyAttributes) {
case 0:
// Press Once
result=createEvent([name: "switch", value: "off", type: "physical"])
sendEvent(name: "status" , value: "Tap ▼")
sendEvent(name: "button" , value: "pushed", data: [buttonNumber: "8"], descriptionText: "$device.displayName Tap-Down-1 (button 8) pressed",
isStateChange: true, type: "$buttonType")
result += createEvent(tapDown1Response("physical"))
result += response("delay 100")
result += createEvent([name: "switch", value: "off", type: "physical"])
break
case 1:
result=createEvent([name: "switch", value: "off", type: "physical"])
Expand Down Expand Up @@ -341,6 +341,18 @@ def zwaveEvent(physicalgraph.zwave.commands.centralscenev1.CentralSceneNotificat
return result
}

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

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

def tapUp2Response(String buttonType) {
sendEvent(name: "status" , value: "Tap ▲▲")
[name: "button", value: "pushed", data: [buttonNumber: "1"], descriptionText: "$device.displayName Tap-Up-2 (button 1) pressed",
Expand Down Expand Up @@ -408,4 +420,4 @@ def configure() {
commands << zwave.versionV1.versionGet().format()
commands << zwave.switchBinaryV1.switchBinaryGet().format()
delayBetween(commands,500)
}
}

0 comments on commit c82f054

Please sign in to comment.