Help Please! - SmartApp not working

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()
}

Did you try it just in the simulator?
If so then try publishing it for your self and try installing normally
You may find it will work… sometimes the simulator can be flakey.

I just copied pasted your code from the preferences lines, changed the double quotes that for some reason are not the normal ones ", published for myself, add it in my smarthing apps and it works fine. It has some few secs lag between the switch action before it spread to the target ones.

Thanks, I’ve tidied up the quotes (don’t know what happened there). I’ve installed it and created another virtual switch. It works fine between the two virtual switches so I’m guessing it must have something to do with how my other switches are setup.

© 2019 SmartThings, Inc. All Rights Reserved. Terms of Use | Privacy Policy

SmartThings; SmartApps®; Physical Graph; Hello, Home; and Hello, Smart Home are all trademarks of the SmartThings, Inc.