Checking Status of Door upon Mode Changing to 'Away'

Hello,

I am not new to Smartthings, but I am failry new to programming custom apps in Groovy. I am trying to create a fairly basic app that checks my garage door status (multisense) upon leaving the house. I have pasted by current code below. I cannot get my door status to not read ‘null’. I’m sure it’s something very basic, but I think I’m following all the examples on the help page.


preferences {
// What door should this app be configured for?
section (“Check these doors”)
{
input “garageDoor”, “capability.contactSensor”
}

section(“Send Notifications?”)
{
input(“recipients”, “contact”, title: “Send notifications to”)
}
}

def installed() {
subscribe(location, “mode”, modeChangeHandler)
}

def modeChangeHandler(evt)
{
def doorState1 = garageDoor.status
def doorState2 = garageDoor.temperature
def doorState3 = garageDoor.contact
log.debug “mode is changed to ${evt.value}”

sendNotificationToContacts(“Mode is changed to ${evt.value}”, recipients)

checkDoor()
}

def checkDoor()
{
sendNotificationToContacts("Garage Door is ${doorState1}, ${doorState2}, ${doorState3} ", recipients)
}

There is an app that already does this if you want to try it instead.

2 Likes

App that already does this aside. (Thanks @greg)

You are defining a var inside a separate method. Those either need to be “states” so they can be read globally, or, define the var inside the checkDoor method.

3 Likes

Thanks. When I place the var inside the checkdoor method, the status is no longer null, but now reads

Garage Door is
physicalgraph.app.AttributeWrapper@206…,
physicalgraph.app.AttributeWrapper@4e6c…

and so forth for each attribute I try to call

Checkout the currentValue method in the docs. :slight_smile:

1 Like