Hi all. I’m having a little issue with an app I made using danny@smartthings’ code for building an IR Bridge. I made the IR sensor with an UNO and the shield, and it works. The app coding I modified a little, only to add a third button. But the problem is I can turn ON my lights, but not off. I can switch the coding around a little, and then I can turn OFF my lights, but not on. Only one or the other. It seems like it is skipping the IF command. I have been trying for a while and just can’t figure it out. Code for the app is posted below.
preferences {
section("Pick an IR device...") {
input "irDevice", "device.IrBridge"
}
section("Button A turns on or off..."){
input "switch1", "capability.switch", title: "This light", required: false
}
section("Button B turns on or off..."){
input "switch2", "capability.switch", title: "This light", required: false
}
section("Button C turns on or off..."){
input "switch3", "capability.switch", title: "This light", required: false
}
}
def installed() {
log.debug "Installed with settings: ${settings}"
subscribe(irDevice, "button.C", handleC)
subscribe(irDevice, "button.B", handleB)
subscribe(irDevice, "button.A", handleA)
}
def updated() {
log.debug "Updated with settings: ${settings}"
unsubscribe()
subscribe(irDevice, "button.C", handleC)
subscribe(irDevice, "button.B", handleB)
subscribe(irDevice, "button.A", handleA)
}
def handleA(evt) {
log.debug "received button A"
if (switch1.currentValue == "on") {
switch1.off()
}
else {
switch1.on()
}
}
def handleB(evt) {
log.debug "received button B"
if (switch2.currentValue == "on") {
switch2.off()
}
else {
switch2.on()
}
}
def handleC(evt) {
log.debug "received button C"
if (switch3.currentValue == "on") {
switch3.off()
}
else {
switch3.on()
}
}
Any help is greatly appreciated!