Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Virtual Momentary button
/**
* Virtual Momentary Button
*/
metadata {
definition (name: "Virtual Momentary Button", namespace: "joshua_lyon", author: "Josh Lyon") {
capability "Switch"
capability "Momentary"
capability "PushableButton"
}
preferences {
}
}
def push(int buttonNumber = 1) {
sendEvent(name: "switch", value: "on")
sendEvent(name: "pushed", value: 1, isStateChange: true)
sendEvent(name: "momentary", value: "pushed", isStateChange: true)
runIn(1,toggleOff)
}
def toggleOff(){
sendEvent(name: "switch", value: "off")
}
def on() {
push()
}
def off() {
push()
}
def installed() {
initialize()
}
def updated() {
initialize()
}
def initialize() {
sendEvent(name: "numberOfButtons", value: 1)
push();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment