SmartApp for 2 doors Open at the same time?


(Ron) #1

Hi - has anyone written a SmartApp for 2 conditions being met simultaneously to trigger an Action? ST Support says they don’t know of one and to ask here, if one can be adapted or someone is willing to write it.

Not knowing the coding language, it would be a fairly simple “If… and If… Then…” command I would think.

Scenario: I have 2 doors (a human door into the garage, and the garage overhead door) that if both are open constitutes a property emergency - the dog can get out onto a busy street (and will, and has…and would ideally involve an alarm of some kind - I have gotten in that much trouble already with the dog getting out! :slight_smile: ))!

They both have open/close sensors and I already have the garage door send a push and text if the outer garage door is open longer than 2 minutes (long enough to put a car in.) The problem would be if someone else opens the human door into the garage - with the dog right there usually - without realizing fast enough the garage door is open - and out scoots the dog into the street! Or someone leaves the human door open (unloading groceries, for instance), unknown to anyone the sneaky dog is now in the garage, and then someone decides to open the garage door to check the mail.

Since I’m new to ST, but it has been easy to set up and works great!, there is also a critical timing element to this action/alert : If there is no way ST/SmartApp would be able to react /notify in critical seconds, then this may not work. So far it seems pretty darn fast! I’d appreciate experience about critical timing of notifications in these kinds of situations. Thanks


(Bruce) #2

This wouldn’t be all that difficult to implement. However, the issue of “critical seconds” could be a problem. There are times, as many here have learned, that ST just doesn’t work at all for several seconds. Events get dropped, or fire late. I see this frequently with rooms whose lights are turned on by motion. Usually (and I underscore that word!) it fires right away within a second. But once in a while, it fires several seconds late or doesn’t fire at all.

What you could do is put a z-wave lock on the interior door, and simply lock that door when the main garage door opens, unlocking it again once the big door is closed. Presumably that lock would face into the garage as the outside, so someone inside would see the deadbolt in the locked position and know that meant not to open the door until the big door is closed.


(Don Woods) #3

I could use this too. I have the same situation with house cats. I need to know if my kitchen door is opened more than a minute while the garage door is open too. I’m going to search different threads to see if I can find anyone has developed anything.


(Paul) #4

I monitor my back gate and back door. If the back door is open, and the gate opens, it triggers an alarm. You can modify the attached code to trigger whatever action you want to happen.

/**
 *  Gate Monitor
 *
 *  Copyright 2015 Paul Toben
 *
 *  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: "Gate Monitor",
    namespace: "",
    author: "Paul Toben",
    description: "If two contacts are open, trigger an alarm",
    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 ("When this door opens/is open...") {
		input "door1", "capability.contactSensor", title: "Where?", required: true
	}
    section ("And this door opens/is open...") {
		input "door2", "capability.contactSensor", title: "Where?", required: true
	}
    section ("Trigger these alarms...") {
		input "alarms", "capability.alarm", title: "Which Alarm(s)", multiple: true, required: true
    }
}

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

def updated() {
	log.debug "Updated with settings: ${settings}"
	unsubscribe()
	initialize()
}

def initialize() {
	subscribe(door1, "contact.open", door1Handler)
    subscribe(door2, "contact.open", door2Handler)
}

def door1Handler(evt) {
	def door2Current = door2.currentContact
    log.debug "door2 current status is $door2Current"

	if (door2.currentContact == "open") {
		alarms.strobe()
    }
}

def door2Handler(evt) {
	def door1Current = door1.currentContact
    log.debug "door1 current status is $door1Current"
	if (door1.currentContact == "open") {
		alarms.strobe()
    }
}

#5

I have a similar scenario – exacerbated this winter by the fact that the exterior garage door wasn’t rolling all the way down all of the time. Sometimes it would go 3/4 of the way and then stop.

I don’t have a permanent solution - but I believe the SmartRules iOS app can potentially help here as it allows you to easily build “AND” conditions in rules. So, I have a single rule set up in that app (the free version) that if my interior garage door is open AND the exterior garage door is open … I get a special push notification “Both garage doors open!” Overall, it works reasonably well (as well as ST does for most anything else).

What I’d really like to do … is have it play a verbal alarm through the Sonos speaker closest to the garage “Both garage doors are open, please make sure the pets didn’t get out!” or something like that.


(Paul) #6

It should be pretty simple to modify the code I posted above to play a message on your Sonos. I don’t have any Sonos speakers, however, so I’ve never tried.


#7

It’s unlikely that smartthings can handle a “Critical seconds” situation for two different reasons.

First, the underlying topology for zigbee and Z wave devices, which are most of the ones that smartthings uses, is mesh, and mesh just doesn’t give you that kind of certainty for anything under less than a minute. The smartthings documentation discusses this. You can try and it may work sometimes, but it’s not something you should bet your dog’s life on.

See the “scheduling limitations” section at the bottom of the following page:

http://docs.smartthings.com/en/latest/smartapp-developers-guide/scheduling.html

Second, the smartthings implementation itself just isn’t consistent at the present time. I have one very simple use case, we have an outer gate and it has a contact sensor on it. When that contact sensor is opened, we should get a push notification which acts as a doorbell for us.

Sometimes it works perfectly, and the bell rings within a second or two of the gate being open. Sometimes it doesn’t ring at all. Sometimes it rings about three minutes later, after the person is already in the house. And sometimes it rings two or three times.

It’s helpful enough that we leave it turned on, but it’s not the kind of thing I would use for any significant barrier breach.

I have a separate alarm system, and in four years we’ve had only one false alarm, and everything else has worked great. But it is more expensive than SmartThings, and I do pay a monthly fee for it.

So it all comes down to what your own priorities are. But in any case I don’t think you can count on smartthings for anything that involves “critical seconds.” But if you’re okay with the kind of inconsistencies I mentioned, then it may be better then not setting it up.

If you think you really need to rely on it, I would look into other solutions.

FWIW


(Ron) #8

Paul - how would i copy this code into my smart apps? Sorry dumb question. I don’t find it in smart apps under convenience or pets, and i don’t know how to get it - where? - so it will work with my sensors. I’m sure there’s a thread about this but not sure what to search for. Duh…


(Paul) #9

@RonaldL52

•Visit http://ide.smartthings.com
•Log-in with your smartthings credentials.
•Click on “My SmartApps”
•Click “New SmartApp” in the upper right hand corner
•Click “From Code” at the top
•Paste the entirety of my code into that window.
•Click Create
•Click “Save” and then click “Publish>For Me” at the top
•Then on the mobile app, you should have a new category called “My Apps” all the way to the right after “Actions” and “More”. You’ll see the app there.

Hope that helps.


(Ron) #10

Paul - this works so great - thank you!! And for explaining IDE and MyApps - got it!


(Paul) #11

Glad it worked! Let us know if there’s anything else we can help you out.
~P