Garage Door Automation

OK I need a little help with my garage door application. I have the Linear Z Wave Relay as well as a multi attached to the door. It opens and closes fine when I use the iPhone app and the open/close state works appropriately. Here is what I’d like to do.

I leave before my wife in the mornings. I’d like for the garage door to close when I leave and then close again when my wife leaves. Then I’d like for it to open when each of us comes home. Seems simple enough I think.

Now I’ve tried using some of the modified Ridiculously Automated Garage Door apps but I have two questions.

What is this used for and what would typical values be

input "openThreshold", "number", title: "Warn when open longer than (optional)",description: "Number of minutes", required: false

And what is this used for and also what would typical values be

section("False alarm threshold (defaults to 10 min)") {
	input "falseAlarmThreshold", "number", title: "Number of minutes", required: false

Here is the entire code for the app.

/**
 *  Ridiculously Automated Garage Door - Modified
 *
 *  Author: SmartThings
 *  Date: 2013-03-10
 *  Modified by chrisb
 *  Date: 2013-09-04
 *
 * Monitors arrival and departure of car(s) and
 *
 *    1) opens door when car arrives,
 *    2) closes door after car has departed (for N minutes),
 *  ----  3) opens door when car door motion is detected, ----  For people who do not have a mutli to use in the car, this part removed.
 *  ----  4) closes door when door was opened due to arrival and interior door is closed. ---- this part removed as well.
 */


// Automatically generated. Make future change here.
definition(
    name: "Open and Close Garage Door",
    namespace: "",
    author: "Greg Harris",
    description: "Open",
    iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
    iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")

preferences {

	section("Garage door") {
		input "doorSensor", "capability.contactSensor", title: "Which sensor?"
		input "doorSwitch", "capability.momentary", title: "Which switch?"
		input "openThreshold", "number", title: "Warn when open longer than (optional)",description: "Number of minutes", required: false
		input "phone", "phone", title: "Warn with text message (optional)", description: "Phone Number", required: false
	}
	section("Car(s) using this garage door") {
		input "cars", "capability.presenceSensor", title: "Presence sensor", description: "Which car(s)?", multiple: true, required: false
	}
	section("False alarm threshold (defaults to 10 min)") {
		input "falseAlarmThreshold", "number", title: "Number of minutes", required: false
	}
}

def installed() {
	log.trace "installed()"
	subscribe()
}

def updated() {
	log.trace "updated()"
	unsubscribe()
	subscribe()
}

def subscribe() {
	log.debug "present: ${cars.collect{it.displayName + ': ' + it.currentPresence}}"
	subscribe(doorSensor, "contact", garageDoorContact)

	subscribe(cars, "presence", carPresence)

}

def doorOpenCheck()
{
	final thresholdMinutes = openThreshold
	if (thresholdMinutes) {
		def currentState = doorSensor.currentState("contact")
		log.debug "doorOpenCheck"
		if (currentState?.value == "open") {
			log.debug "open for ${now() - currentState.date.time}, openDoorNotificationSent: ${state.openDoorNotificationSent}"
			if (!state.openDoorNotificationSent && now() - currentState.date.time > thresholdMinutes * 60 *1000) {
				def msg = "${doorSwitch.displayName} was been open for ${thresholdMinutes} minutes"
				log.info msg
				sendPush msg
				if (phone) {
					sendSms phone, msg
				}
				state.openDoorNotificationSent = true
			}
		}
		else {
			state.openDoorNotificationSent = false
		}
	}
}

def carPresence(evt)
{
	log.info "$evt.name: $evt.value"
	// time in which there must be no "not present" events in order to open the door
	final openDoorAwayInterval = falseAlarmThreshold ? falseAlarmThreshold * 60 : 600

	if (evt.value == "present") {
		// A car comes home

		def car = getCar(evt)
		def t0 = new Date(now() - (openDoorAwayInterval * 1000))
		def states = car.statesSince("presence", t0)
		def recentNotPresentState = states.find{it.value == "not present"}

		if (recentNotPresentState) {
			log.debug "Not opening ${doorSwitch.displayName} since car was not present at ${recentNotPresentState.date}, less than ${openDoorAwayInterval} sec ago"
		}
		else {
			if (doorSensor.currentContact == "closed") {
				openDoor()
				sendPush "Opening garage door due to arrival of ${car.displayName}"
				state.appOpenedDoor = now()
			}
			else {
				log.debug "door already open"
			}
		}
	}
	else {
		// A car departs
		if (doorSensor.currentContact == "open") {
			closeDoor()
			log.debug "Closing ${doorSwitch.displayName} after departure"
			sendPush("Closing ${doorSwitch.displayName} after departure")
		}
		else {
			log.debug "Not closing ${doorSwitch.displayName} because its already closed"
		}
	}
}

def garageDoorContact(evt)
{
	log.info "garageDoorContact, $evt.name: $evt.value"
	if (evt.value == "open") {
		schedule("0 * * * * ?", "doorOpenCheck")
	}
	else {
		unschedule("doorOpenCheck")
	}
}

private openDoor()
{
	if (doorSensor.currentContact == "closed") {
		log.debug "opening door"
		doorSwitch.push()
	}
}

private closeDoor()
{
	if (doorSensor.currentContact == "open") {
		log.debug "closing door"
		doorSwitch.push()
	}
}

private getCar(evt)
{
	cars.find{it.id == evt.deviceId}
}

Thanks in advance

I think this is used to notify if your garage door is still open, like both you and your wife are at work but the door is still open. The problem with having things automated is that there can bugs and you don’t want your door open while you’re not home.

Typical value? Up to you. I would say over an hour, that way it won’t go off if you’re washing your car or something.

Thresholds are typically used to prevent accidental triggers. The garage door needs to be open for X amount of time before it takes said action. Accidental triggers can happen for all sorts of things; such as your presence sensor is on the edge of your geofence, battery is low in your sensor, poor signal to base station, etc. Simply, this time is used to prevent your garage door from opening and closing all of the time.

Default time is 10 minutes.

Edit:
As chrisb states below, above should read:

The sensor needs to be on for X amount of time before it takes said action…

Thresholds are typically used to prevent accidental triggers. The garage door needs to be open for X amount of time before it takes said action. Accidental triggers can happen for all sorts of things; such as your presence sensor is on the edge of your geofence, battery is low in your sensor, poor signal to base station, etc. Simply, this time is used to prevent your garage door from opening and closing all of the time.

Default time is 10 minutes.
[/quote]

Nick nailed it, except for one correction. The threshold is for how long the presence sensor is gone, not how long the door is open. Just a “miss-type” I’m sure on Nick’s part.

The sensor needs to be gone, for example, 10 minutes before the SmartApp will open the door upon return. This is, as Nick said, to prevent an accidental trigger if your sensor is just at the edge of the Zigbee network range or low on batteries or whatever.

Haha, yeah, I mistyped. I was typing this from my mobile phone and it took so long that I couldn’t get my thought straight. ;-).