Help For Beginner

I am trying to learn to write a simple app. I want to monitor a switch for a given light and turn on another light based on the original switch. The code is shown below. For a while I got nothing to happen at all. Now, I can save my code and publish “For Me”. The app shows up on my iPhone and I can try to install it. After setting “theInputSwitch”, “theOutputSwitch”, and the name of the app, I hit done and get …

org.springframework.security.access.AccessDeniedException: Access is denied

Any clues? This is frustrating for a beginner. Note, I know this is like the app “BigSwitch”. I was just using it as an example to begin to understand the development process and what is possible.

Thanks

/**

  • LightsOffAfterTime
  • Copyright 2015 Jack (Butch) Griffin, butchg@comast.net
  • 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: “LightsOffAfterTime”,
namespace: “sjcbulldog”,
author: "butchg@comast.net",
description: “Turn off lights a fixed amount of time after they were turned off, either manually or via a smartthings app.”,
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(“The Input Switch To Monitor …”) {
input “theInputSwitch”, “capability.switch”
}
section(“The Output Switch To Control …”) {
input “theOutputSwitch”, “capability.switch”
}
}

def installed() {
subscribe(“theInputSwitch”, “switch.on”, switchOnHandler)
}

def updated() {
log.debug(“Bwg Lights App - Updated”)
}

def switchOnHandler(evt) {
log.debug(“BWG Lights App - Handling Switch On Event”)
theOutputSwitch.on([delay: 1000])
}

1 Like

The problem is in

subscribe("theInputSwitch", "switch.on", switchOnHandler)

It should be this instead

subscribe(theInputSwitch, "switch.on", switchOnHandler)
1 Like