Seems to work kinda .. you can pick a Button device, pick the lights, pick the button.
but the lights do not turn on
What Am I doing wrong ?
input "buttonDevice", "capability.pushableButton"
IS the only way I found to get a list of my "switches and battery operated 4-button remotes
preferences {
section("Settings") {
input "buttonDevice", "capability.pushableButton", title: "Select Button Device", multiple: false, required: true
input "lights", "capability.switch", title: "Pick Lights to Turn On", multiple: true, required: false
input "selectedButton", "enum", title: "Select Button to Turn On Lights", options: ["1", "2", "3", "4"], required: true, defaultValue: "1"
}
}
def installed() {
subscribe(buttonDevice, "button", buttonHandler)
}
def updated() {
unsubscribe()
subscribe(buttonDevice, "button", buttonHandler)
}
def buttonHandler(evt) {
log.debug "Button ${buttonDevice} was pressed with value: ${evt.value}"
if (evt.value == "pushed" && evt.displayName == selectedButton) {
turnOnLights()
} else {
log.warn "Button press event with unexpected value: ${evt.value} or unexpected button: ${evt.displayName}"
}
}
def turnOnLights() {
log.debug "Turning on lights with button: ${selectedButton}"
lights.each { light ->
light.on()
}
}