# Help with garage door left open app

**URL:** <https://community.smartthings.com/t/help-with-garage-door-left-open-app/122320>\
**Category:** Writing SmartApps\
**Created:** [March 20, 2018, 3:46pm UTC](https://community.smartthings.com/t/help-with-garage-door-left-open-app/122320 "2018-03-20T15:46:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jdoniz](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@Jdoniz](https://community.smartthings.com/u/Jdoniz)\
**Post date:** [March 20, 2018, 3:46pm UTC](https://community.smartthings.com/t/help-with-garage-door-left-open-app/122320/1 "2018-03-20T15:46:48Z")

</div>

this is code ffor app i found but would rather have it send a text than a notification, can anybody help with that code change?

/\*\*

- Is It Closed?
- 
- Copyright 2014 Greg Bronzert
- 
- 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: “Is It Closed?”,  
namespace: “gbknet”,  
author: “Greg Bronzert”,  
description: “Check whether door is closed after a mode change or specific time.”,  
category: “Convenience”,  
iconUrl: “[https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png](https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png)”,  
iconX2Url: “[https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png](https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png)”  
)

preferences {  
section(“Which mode changes trigger the check?”) {  
input “newMode”, “mode”, title: “Which?”, multiple: true, required: false  
}  
section(“When should I check? (once per day)”) {  
input “timeToCheck”, “time”, title: “(Optional)”, required: false  
}  
section(“Which doors should I check?”){  
input “doors”, “capability.doorControl”, title: “Which?”, multiple: true, required: true  
}  
}

def installed() {  
log.debug “Installed with settings: ${settings}”

```
initialize()

```

}

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

```
unsubscribe()
unschedule()
initialize()

```

}

def initialize() {  
if (newMode != null) {  
subscribe(location, modeChangeHandler)  
}  
if (timeToCheck != null) {  
schedule(timeToCheck, checkDoor)  
}  
}

def modeChangeHandler(evt) {  
log.debug “Mode change to: ${evt.value}”

```
doors.each {
    if (newMode.any{ it == evt.value } || newMode == evt.value) {
        checkDoor(it)
    }
}

```

}

def checkDoor(door) {  
log.debug "Door ${door.displayName} is ${door.currentContact}"  
if (door.currentContact == “open”) {  
def msg = "${door.displayName} was left open, closing it!"  
log.info msg  
sendNotificationEvent(msg)  
closeDoor(door);  
} else {  
def msg = "${door.displayName} was not open, we are good."  
log.debug msg  
sendNotificationEvent(msg)  
}  
}

private closeDoor(door) {  
if (door.currentContact == “open”) {  
log.debug "closing door"  
door.close()  
}  
}  
Thanks

---

<div class="post-metadata">

**Author:** ![lmosenko](https://avatars.discourse-cdn.com/v4/letter/l/a698b9/32.png) [@lmosenko](https://community.smartthings.com/u/lmosenko)\
**Post date:** [March 20, 2018, 4:06pm UTC](https://community.smartthings.com/t/help-with-garage-door-left-open-app/122320/2 "2018-03-20T16:06:33Z")

</div>

Hi @Jdoniz,

That sounds like a great start, but you can already do this via the WebCore/CoRe community rule engine. I have it working via the Core.

---

<div class="post-metadata">

**Author:** ![vseven](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/vseven/32/35333_2.png) [@vseven](https://community.smartthings.com/u/vseven)\
**Post date:** [March 20, 2018, 6:44pm UTC](https://community.smartthings.com/t/help-with-garage-door-left-open-app/122320/3 "2018-03-20T18:44:47Z")

</div>

Why not just use a custom rule in Smart Home Monitor? I have these setup for all my exterior doors in case we accidentally leave one open. Its already built into the app and will do exactly what you want.

---

<div class="post-metadata">

**Author:** ![Jdoniz](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@Jdoniz](https://community.smartthings.com/u/Jdoniz)\
**Post date:** [March 20, 2018, 7:05pm UTC](https://community.smartthings.com/t/help-with-garage-door-left-open-app/122320/4 "2018-03-20T19:05:47Z")

</div>

it doesn’t work for me, because when my mode changes to away the door is already open, and it looks to see if the door is opening not left open, I appreciate any advice how you have it setup

---

<div class="post-metadata">

**Author:** ![Jdoniz](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@Jdoniz](https://community.smartthings.com/u/Jdoniz)\
**Post date:** [March 20, 2018, 7:06pm UTC](https://community.smartthings.com/t/help-with-garage-door-left-open-app/122320/5 "2018-03-20T19:06:54Z")

</div>

i’m pretty new to this - i do not know what Webcore/Core is

---

<div class="post-metadata">

**Author:** ![rontalley](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@rontalley](https://community.smartthings.com/u/rontalley)\
**Post date:** [March 20, 2018, 7:08pm UTC](https://community.smartthings.com/t/help-with-garage-door-left-open-app/122320/6 "2018-03-20T19:08:23Z")

</div>

I just use webCoRE to make my own rules. Install webCoRE! You will not regret and you will be making your own rules in no time.

Here’s an example, although not created to your exact request, it can be easily modified to fit your likings:

 ![IMG_1564](https://global.discourse-cdn.com/smartthings/original/3X/6/6/66b5f9fffcbeeb97a2a13a003a82d5d93bf55efa.PNG)

---

<div class="post-metadata">

**Author:** ![jkp](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jkp/32/117130_2.png) [@jkp](https://community.smartthings.com/u/jkp)\
**Post date:** [March 20, 2018, 7:27pm UTC](https://community.smartthings.com/t/help-with-garage-door-left-open-app/122320/8 "2018-03-20T19:27:52Z")

</div>

> [@lmosenko](#):
>
> Can you remove that CODE from your screenshot? It is private key to your system!

How does sharing a piston become a private key to his system?

---

<div class="post-metadata">

**Author:** ![rontalley](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@rontalley](https://community.smartthings.com/u/rontalley)\
**Post date:** [March 20, 2018, 7:32pm UTC](https://community.smartthings.com/t/help-with-garage-door-left-open-app/122320/9 "2018-03-20T19:32:38Z")

</div>

The Code is what you use to import the Piston…

---

<div class="post-metadata">

**Author:** ![lmosenko](https://avatars.discourse-cdn.com/v4/letter/l/a698b9/32.png) [@lmosenko](https://community.smartthings.com/u/lmosenko)\
**Post date:** [March 20, 2018, 8:01pm UTC](https://community.smartthings.com/t/help-with-garage-door-left-open-app/122320/10 "2018-03-20T20:01:53Z")

</div>

I stand corrected.

---

<div class="post-metadata">

**Author:** ![Jdoniz](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@Jdoniz](https://community.smartthings.com/u/Jdoniz)\
**Post date:** [March 20, 2018, 8:29pm UTC](https://community.smartthings.com/t/help-with-garage-door-left-open-app/122320/11 "2018-03-20T20:29:10Z")

</div>

I researched Webcore - got it loaded which wasn’t real easy but once loaded i was able to do what i wanted in a few minutes. Pretty easy - i am excited to do other things now where as before i was reluctant because it was so hard - thanks for all the help!!!

---

<div class="post-metadata">

**Author:** ![dshehane](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/dshehane/32/80741_2.png) [@dshehane](https://community.smartthings.com/u/dshehane)\
**Post date:** [April 9, 2019, 4:51pm UTC](https://community.smartthings.com/t/help-with-garage-door-left-open-app/122320/12 "2019-04-09T16:51:51Z")

</div>

The code at the first of this thread does exactly what I want! However, when I copy and paste as code into SmartApp it gives me this error when I try to create.

startup failed: script\_app\_metadata\_441b1ea6\_b8ad\_4dd7\_9fe9\_45d61d66f715: 2: unexpected token: It @ line 2, column 11. name: “Is It Closed?”, ^ 1 error

I am a real newbie at this…can anyone help?
