[OBSOLETE] Garage Door Sunset Monitor

Hi everyone,

I’ve designed a SmartApp that I’d like to share, the Garage Door Sunset Monitor:

This app was inspired by a couple other great projects:

But I was looking for something a bit different.

The Garage Door Sunset Monitor is designed to notify you if your garage door (or any other contact sensor) is open after dark, or some other preset times.

Features:

  • You can monitor any number of doors
  • You can monitor based on sunset/sunrise (+/- X minutes), or, at specific times of the day
  • You can decide how long the doors can be open before you’re alerted

I’ve been using the app for a while at my home and it has been working reliably.

Please let me know if you use it!

8 Likes

Ah, I was going to work on something like this soon!

This thing is amazing. Is it possible to have a switch activated if the threshold is reached? For example, I have some cameras in my garage where it would be nice to turn the switch on the controls the cameras and off when clearde. Thanks! You guys make me really come back to ST because of the craftsmanship in your work! That s to all smartapp community authors! Where can I donated?

1 Like

@pmusselman Glad it helps! You should be able to update the app to turn on/off switches when the alarm fires. You’ll want to have a preference for capability.switch and then just turn it .on(). Let me know if you can’t get it going!

1 Like

Awesome. I’m going to give it a try.

For clarification, how do you setup a time check if you don’t want to use Sunset. Say I want to do 9 PM every night. Is that possible and how do you set it in the smart app? Thanks.

Yep! You should be able to do a time-based system easily. Here’s one of my other apps that has time preferences:

1 Like

@nicjansma ,

I use the “Garage Door Sunset Monitor” and have had a couple of false positive notifications.

Here’s the details from this morning:

2016-11-08 5:38:04.918 AM GMT
DEVICE   Door - Garage Roller contact is open

2016-11-08 5:38:06.101 AM GMT
Alert: Its sunset and Door - Garage Roller is open for 30 minutes		Push (OK)

2016-11-08 5:38:54.442 AM GMT	
DEVICE		contact	closed 		Door - Garage Roller contact is closed 

2016-11-08 5:43:06.038 AM GMT
OK: Door - Garage Roller closed		Push (OK)

Any ideas what might be causing it? As you can see from the contact sensor details above the door was open for less than 60 seconds.

Cheers.

Hi @brumster – what do you have “Alert Thresholds” set to? 30 minutes?

How many doors do you have? If you have more than one, I think I’ve spotted a bug in the code.

Thanks for getting back to me @nicjansma

Threshold set to 30. Only now door installed.

@brumster OK, if you have only one door then I’m not sure where the bug would be.

Mind sharing the device logs at all? Might help us determine what’s going on.

Let me see if it does it again and when it does I’ll give you the full break down. Thx.

I noticed this issue too so I debugged the code. I think the problem is that the state.threshold is not reset if the door closes before the threshold is met. So made this change to checkdoors(). I have not tested this code yet but I will in the next few days

def checkDoors() {
    // if we're doing Time of Day monitoring, see if this is within the times they specified
    if (monitoringType == "Time of Day") {
        def currTime = now()
        def eveningStartTime = timeToday(startMonitoring)
        def morningEndTime = timeToday(stopMonitoring)

        state.monitoring = currTime >= eveningStartTime.time || currTime <= morningEndTime.time
    }

    log.info "checkDoors: Should we check? $state.monitoring"

    if (!state.monitoring) {
        return
    }

    doors?.each { door ->
        def doorName = door.displayName
        def doorOpen = checkDoor(door)

        log.debug("checkDoors: Door $doorName: $doorOpen, previous state: " + state.opened[doorName])

        if (doorOpen == "open" && !state.opened[doorName]) {
            // previously closed, now open
            state.threshold = state.threshold + 5
            log.debug("checkDoors: Door was closed, is now open.  Threshold check: ${state.threshold} minutes (need " + threshold + "minutes)")

            if (state.threshold >= threshold) {
                log.debug("checkDoors: Door has been open past threshold, sending an alert")

                send("Alert: It's sunset and $doorName is open for $threshold minutes")
                state.opened[doorName] = true
            }
        } else if (doorOpen == "closed" && state.opened[doorName]) {
            // previously open, now closed
            log.debug("checkDoors: Door had been previously open, is now closed")

            send("OK: $doorName closed")

            state.opened[doorName] = false
            state.threshold = 0
        } else if (doorOpen == "closed"){
            // Door closed before threshold, reset threshold
            log.debug("checkDoors: Door closed before " + threshold + " threshold.  Threshold check: ${state.threshold} minutes (threshold reset to 0)")
            state.threshold = 0
        }
    }
}
1 Like

Great catch Eric! Would you be able to open a PR? https://github.com/nicjansma/smart-things

New user question… Do I just log in to https://graph.api.smartthings.com, click on “My SmartApps” > New SmartApp" > From Code > Paste your GitHub code > Click Create > Click Publish?

Then it should show up in the ST app? That’s what I did and it’s not showing up…

Thanks for any help.

Always login to https://account.smartthings.com and then it will redirect you to your correct shard (url).

This is more than likely why you can’t see it in Marketplace. After you logout / login with the above url, note the shard you are redirected to (more than likely not graph.api…). If you don’t see the SmartApp there, then recreate it again and publish for you. Then it will show in Marketplace.

Thank you!! That worked!!

1 Like

Can you do me a favor and mark that post above as a solution. Click the check box ✓. That way it will help others in the future if they come across this. :slight_smile:

Sorry mate… I don’t see any check box…

Click on the … on that post and then you should see checkbox.