Error on Virtual Device Types

I’m trying to write my first SmartApp, but I get the following error when trying to run it in the Simulator using virtual device types. The error I get is:

org.springframework.security.access.AccessDeniedException: Access is denied @ line 52

Line 52 is:
subscribe(partnerOnePresence, “presence”, presenceChangeRouter)

Note that I have a log.debug immediately before that line, and for some reason it is not showing up into the log output.

Any suggestions on what is going on?

Code:

/**

  • HomeAwayControl2
  • Copyright 2015 Taylor Lehman
  • 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: “HomeAwayControl2”,
namespace: “taylorlehman”,
author: “Taylor Lehman”,
description: “Automating When I arrive and leave”,
category: “Family”,
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”,
oauth: true)

/*
The preferences data structure drives the UI the user sees whuile installing the app that
instructs them to select their preferences.
*/
preferences {
section(“Please Select the Presence Sensors to Track”) {
input “partnerOnePresence”, “capability.presenceSensor”, required: true
input “partnerTwoPresence”, “capability.presenceSensor”, required: true
}
}

def installed() {
log.debug "Installed with settings: ${settings}"
initialize()
}

def updated() {
log.debug “Updated with settings: ${settings}”

unsubscribe()
initialize()

}

def initialize() {
log.debug "EVENTOCCURRED"
subscribe(partnerOnePresence, “presence”, presenceChangeRouter)
subscribe(partnerTwoPresence, “presence”, presenceChangeRouter)
}

/*
This method gets called by the smartthings event handling system when the presence
state of one of the partner’s presence state has changed.
*/
def presenceChangeRouter(presenceEvent){
log.debug "EVENTOCCURRED"
if(presenceEvent.value == “present”){
/The sensor became present - if one person is present,
we want the home to be in the present state
/
setHome()
} else {
/The presence sensor is not present - we only want to put the home
into not-present state if the other partner is also away
/
if(!isOtherPartnerPresent(presenceEvent.device)){
setAway()
}
}
}

def isOtherPartnerPresent(device){
log.debug “Current device is ${device.name}”

def partnerSensor = partnerOnePresence

if(device.name == "partnerOnePresence"){
	partnerSensor = partnerTwoPresence
}

log.debug "Partner devicer is ${partnerSensor.name}"

if(partnerSensor.presenceState == "present"){
	log.debug "Partner is Present"
	return true
} else {
	log.debug "Partner is Not Present"
	return false
}

}

def setHome(){
log.debug “Someone’s home! Let’s wake the house back up”

//TODO: Tell nest we are home (which should turn off the camera and turn up the heat)

}

def setAway(){
log.debug “Everyone is gone! Let’s shut the house down”

//TODO: Put the garage door down if it is up
//TODO: Tell nest we are away (which should turn on the camera and turn down the heat)

}

Hey Folks - Just tried to run the sample app as well - same error when using virtual devices (error when trying to subscribe). How do I file a bug on virtual devices not working?

Thanks!
Taylor

@Dianoga

Any ideas? :smile:

Hey Tim - I think there is still an issue with virtual device types (or maybe I just don’t understand how they work), but I was able to get past the access denied error by creating virtual presence sensors in the devices section and then using them.

However, I’m now seeing an issue where no logging is showing up (even the logging in my install and initialize methods). I’m logging everything as log.debug.

Any idea why the logging is not showing up?

Friendly ping here. Any help would be appreciated. Still not seeing any logging showing up. At this point, I’m ready to abandon SmartThings as this development platform is just terrible.

Have you submitted a support ticket so we can track and assign this to an engineer?