Hi,
I’ve written my first SmartApp and for whatever reason its not working. The sections work fine in the Simulator, the two selected switches load, but from then on nothing happens. The logs don’t register the first switch and nothing happens when its triggered. Any help in deciphering what I’ve done incorrectly would be most appreciated.
/**
- Assign Virtual switch
- Copyright 2017 Mark Graham
- 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: “Assign Virtual switch”,
namespace: “Assign Virtual Switch”,
author: “Mark Graham”,
description: “Assigns Virtual switch to a real device”,
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(“Use this Switch …”) {
input “switch1”, “capability.switch”, multiple: false
}
section(“Control this switch …”) {
input “switch2”, “capability.switch”, multiple: true}
}
def updated() {
log.debug "Installed with settings: ${settings}"
subscribe(switch1,“switch.on”, switchOnHandler)
subscribe(switch1,“switch.off”, switchOffHandler)
}
def installed() {
log.debug "Installed with settings: ${settings}"
subscribe(switch1,“switch.on”, switchOnHandler)
subscribe(switch1,“switch.off”, switchOffHandler)
}
def switchOnHandler(evt) {
log.debug "switch turned on!"
switch2.on()
}
def switchOffHandler(evt) {
log.debug "switch turned off!"
switch2.off()
}