Garage Door Monitor

Here’s a little app which will monitor your garage doors and alert you if they remain open for longer than you would like. It’s always a terrible feeling when you realize that you left the garage door open all evening, or throughout the heat of the day.

You can also specify some motion sensors which will reset the counter, so that it won’t continually alert you if you are working in the garage.

definition
(
    name: "Garage Door Monitor",
    namespace: "OMH",
    author: "Outsmarting My Home",
    description: "Monitors a garage door and sends alerts if it's been open for the specified time with no motion detected.",
    category: "Safety & Security",
    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("Motion Sensors") 
    { 
        input "MotionSensors", "capability.motionSensor", required: false, multiple: true, title:"Motion Sensors" 
    }
    section("Garage Doors") 
    {
        input "Door", "capability.contactSensor", required: true, multiple: false, title:"Door" 
    }
    section("Send Push Notification?")
    {
        input "sendPush", "bool", required: false, title: "Send Push Notification when Opened?"
    }
    section("Wait Time")
    {
        input "waitTime", "number", title: "Time To Wait (minutes)", required: true
    }
}

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

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

def initialize() 
{ 
   subscribe(MotionSensors, "motion.active", motionDetectedHandler)
   subscribe(Door, "contact.open", doorOpenedHandler);
   subscribe(Door, "contact.closed", doorClosedHandler);
}

def motionDetectedHandler(evt)
{
    log.debug "Motion Detected $evt"
    state.openedAt = now()
}

def doorOpenedHandler(evt)
{ 
    state.doorOpened = true
    state.openedAt = now()
    log.debug "Exterior Door Opened. Will check again in " + (waitTime * 60) + " seconds.";
    runIn(waitTime * 60, checkAlert)
}

def doorClosedHandler(evt)
{
    state.doorOpened = false;
}

def checkAlert()
{
    log.debug "Garage Door Monitor. CheckAlert. " + Door.displayName;
    if (state.doorOpened)
    {
        log.debug Door.displayName + " is open."
        def minutesOpen = (now() - state.openedAt) / 1000 / 60
        log.debug Door.displayName + " has been open for " + minutesOpen + " minutes."
        if (minutesOpen >= waitTime)
        {
            log.debug "Sending Notification"
            if (sendPush)
            {
                log.debug "Sending Push Notification."
                //sendNotificationToContacts("Garage Door, " + Door.displayName + ", Is Open for " + minutesOpen + " minutes!", recipients)
                sendPush("The ${Door.displayName} is open!")
            }
            runIn(300, checkAlert)
        }
    }
}

Recent Content

link to Baby Dimmer Control

Baby Dimmer Control

Manage your Baby’s dimmer   This little app will help control the dimmer switch in your baby’s nursery, or any other dimmer switch. Perhaps late at night you don’t want the light at 100% brightness. This app will take care of that by allowing you to specify a time and what level to set the […]