In case it is helpful to anyone, you’ll find the SmartApp below that I used with the 3-button contact switch to control selected devices.
/**
* 3 Button Switch for Light and Plug Control
*
* Copyright 2014 Seth Jansen
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
definition(
name: "3 Button Switch for Light and Plug Control",
namespace: "",
author: "Seth Jansen",
description: "Turn on/off lights, plug-loads, or other events using a 3-button switch where...",
category: "My Apps",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
preferences {
section ("Select your 3-button switch") {
input "contact1", "capability.contactSensor"
}
section ("Select loads for each button to turn on/off") {
input "switch1", "capability.switch", title: "Button 1:"
input "switch2", "capability.switch", title: "Button 2:"
input "switch3", "capability.switch", title: "Button 3:"
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
initialize()
}
def initialize() {
subscribe(contact1, "contact", contactChangeHandler)
subscribe(contact1, "contact2", contactChangeHandler)
subscribe(contact1, "contact3", contactChangeHandler)
}
def contactChangeHandler(evt) {
log.debug "$evt.name"
log.debug "$evt.value"
def switchState = switch1.currentValue('switch')
log.debug "$switchState"
if (evt.name == "contact") {
if (switch1.currentValue('switch') == "off") {
switch1.on()
} else if (switch1.currentValue('switch') == "on") {
switch1.off()
}
} else if (evt.name == "contact2") {
if (switch2.currentValue('switch') == "off") {
switch2.on()
} else if (switch2.currentValue('switch') == "on") {
switch2.off()
}
} else if (evt.name == "contact3") {
if (switch3.currentValue('switch') == "off") {
switch3.on()
} else if (switch3.currentValue('switch') == "on") {
switch3.off()
}
}
}