Left garage door - notification

I have a SmartThings Multi Purpose Sensor on my garage door and I want it to activate another device when the door has been open for X minutes. I try to create a scene where it triggers another device, such as lighting a lamp, letting a lamp flash, or in some other way alerting me that the garage door seems to be left in an open position.

I have found the possibility, for example, to light a lamp if the door is opened, but I only want it to be lit or triggered if the door has been open “for too long”. Is this possible?

1 Like

WebCoRE can do this…

1 Like

Thanks, but is there any easier way to solve the problem?

1 Like
2 Likes

Hello, @samlyr

In addition of what @jkp has shared about the Rules, you could implement the next example at the Rules API that describes the workflow you need:

{
    "name": "If garage door left opened for 5 minutes, advice light will flash one",
    "actions": [
        {
            "if": {
                "equals": {
                    "left": {
                        "device": {
                            "devices": ["yourGarageContactSensor"],
                            "component": "main", 
                            "capability": "contactSensor",
                            "attribute": "contact"
                        }
                    },
                    "right": {
                        "string": "open"
                    }
                }
            },
            "then": [
                {
                    "sleep": {
                        "duration": {
                            "value": {
                                "integer": 5
                            }
                        },
                        "unit": "Minute"
                    }
                },
                {
                    "command": {
                        "devices": ["someLightId"],
                        "commands": [
                            {
                                "component": "main",
                                "capability": "switch",
                                "command": "on",
                                "arguments": []
                            }
                        ]
                    }
                },
                {
                    "command": {
                        "devices": ["someLightId"],
                        "commands": [
                            {
                                "component": "main",
                                "capability": "switch",
                                "command": "off",
                                "arguments": []
                            }
                        ]
                    }
                }
            ],
            "else": []
        }
    ]
}

I hope this information results useful for you,

Erick.

1 Like

GitHub seems to be unavailable in Europe. So instead I tried to create an own Smart App from the templates in my Samsung SmartThings account. I used two different templates and tried to copy / paste parts from one of them to the other. At first I believed I have nailed it and was feeling proud and smart for a short while. :grin:

But then reality smacked me in my face when it turned out that the app kept sending me notifications about the garage door still being open, even though it was closed. :lying_face: :grimacing:

Is there anyone who could help me with the template so that the result will be:

“Notifies me when I have left a door or window open longer that a specified amount of time by turning on a switch or a light”.

I will post the “main template” below.

/**

  • Copyright 2015 SmartThings
  • 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.
  • Garage Door Monitor
  • Author: SmartThings
    */
    definition(
    name: “Garage Door Monitor”,
    namespace: “smartthings”,
    author: “SmartThings”,
    description: “Monitor your garage door and get a text message if it is open too long”,
    category: “Safety & Security”,
    iconUrl: “https://s3.amazonaws.com/smartapp-icons/Meta/garage_contact.png”,
    iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Meta/garage_contact@2x.png
    )

preferences {
section(“When the garage door is open…”) {
input “multisensor”, “capability.threeAxis”, title: “Which?”
}
section(“For too long…”) {
input “maxOpenTime”, “number”, title: “Minutes?”
}
section(“Text me at (optional, sends a push notification if not specified)…”) {
input(“recipients”, “contact”, title: “Notify”, description: “Send notifications to”) {
input “phone”, “phone”, title: “Phone number?”, required: false
}
}
}

def installed()
{
subscribe(multisensor, “acceleration”, accelerationHandler)
}

def updated()
{
unsubscribe()
subscribe(multisensor, “acceleration”, accelerationHandler)
}

def accelerationHandler(evt) {
def latestThreeAxisState = multisensor.threeAxisState // e.g.: 0,0,-1000
if (latestThreeAxisState) {
def isOpen = Math.abs(latestThreeAxisState.xyzValue.z) > 250 // TODO: Test that this value works in most cases…
def isNotScheduled = state.status != “scheduled”

	if (!isOpen) {
		clearSmsHistory()
		clearStatus()
	}

	if (isOpen && isNotScheduled) {
		runIn(maxOpenTime * 60, takeAction, [overwrite: false])
		state.status = "scheduled"
	}

}
else {
	log.warn "COULD NOT FIND LATEST 3-AXIS STATE FOR: ${multisensor}"
}

}

def takeAction(){
if (state.status == “scheduled”)
{
def deltaMillis = 1000 * 60 * maxOpenTime
def timeAgo = new Date(now() - deltaMillis)
def openTooLong = multisensor.threeAxisState.dateCreated.toSystemDate() < timeAgo

	def recentTexts = state.smsHistory.find { it.sentDate.toSystemDate() > timeAgo }

	if (!recentTexts) {
		sendTextMessage()
	}
	runIn(maxOpenTime * 60, takeAction, [overwrite: false])
} else {
	log.trace "Status is no longer scheduled. Not sending text."
}

}

def sendTextMessage() {
log.debug “$multisensor was open too long, texting phone”

updateSmsHistory()
def openMinutes = maxOpenTime * (state.smsHistory?.size() ?: 1)
def msg = "Your ${multisensor.label ?: multisensor.name} has been open for more than ${openMinutes} minutes!"
if (location.contactBookEnabled) {
    sendNotificationToContacts(msg, recipients)
}
else {
    if (phone) {
        sendSms(phone, msg)
    } else {
        sendPush msg
    }
}

}

def updateSmsHistory() {
if (!state.smsHistory) state.smsHistory =

if(state.smsHistory.size() > 9) {
	log.debug "SmsHistory is too big, reducing size"
	state.smsHistory = state.smsHistory[-9..-1]
}
state.smsHistory << [sentDate: new Date().toSystemFormat()]

}

def clearSmsHistory() {
state.smsHistory = null
}

def clearStatus() {
state.status = null
}

This won’t trigger a device or anything, but you can sure make it annoying by continuously notifying you that it’s open.

Do yourself a favor, huge favor, and install webCoRE and start making rules the easy way.

It’s a one time install and will enable you to do above and beyond what you thought was possible in an easy to understand interface with the ability to copy and save your rules. Might not last forever when they finally switch over but it will give you everything you need now.

I just did something similar. I have a multipurpose sensor mounted on each of my garage doors (as a contact sensor – I wanted to know if the door was open just inches). I added a Smart Home Monitor rule that triggers once if either door has been open for more than 10 minutes. I have it set to start checking at 9PM. I also have Echo Speaks installed, and I have the SHM rule send a notification about the open garage door as a push, an SMS, and have it talk out my Alexa. You could have the SHM rule turn on a lamp (or flash a multi-color bulb).

webCoRE is probably a great tool, but to use it I need GitHub (as far as I have understood) and GitHub is for some reason no longer available in Europe.

You can manually install via the IDE…Goto the Wiki.

I created a simple automation rule using a hue color bulb. If the garage is open, the light comes on red and when it is closed it turns off.

Additionally, I have the ‘if’ side of the rule tied to another outside light so if the lights are on outside and the garage is closed, it reverts to on and switches to warm white to match the color temperature of the other lights. It has helped a great deal, if I look outside I see the red light and I know that I left the door open.

I also have made my garage door sensor available to Google Home, so my backup is to ask Google if the garage is open.

I’m new to SmartThings - I previously had a Wink home hub, but lack of support caused me to toss it.
I’m trying to set up notification if my garage door is left open for more than 10 minutes, like you have here. But in my SmartThings app, I cannot locate how to set up a SHM rule. All I can find is a security area, where it will notify if any door monitor is opened, but can’t parse out to a single door (garage) and then have a time-out before notification is sent. (Was very easy to do in Wink).

Am I looking in the wrong place?

Wayne