Garage door script that notifies when garage open during "dark" hours


1) Give a description of the problem
How would one design a script that sends a notification when a contact is open for 30 minutes during “dark” hours (i.e. sunset to sunrise), REGARDLESS of when it was originally opened (i.e. it could have been opened originally during daylight hours)?

2) What is the expected behaviour?
A notification is sent when a contact has been opened for x minutes of “dark” hours.

3) What is happening/not happening?
My script works fine if the contact is opened during the “dark” hours. But if it is opened during “daylight” hours and then the sun goes down, it never triggers.

4) Post a Green Snapshot of the pistonimage


It will require two triggers… One for each scenario.


a simple way would be,
ADDING another IF block or a timer,

IF time happens every day at sunset
        IF the garage door IS open (condition)
        Send SMS

in this way if it was open before sunset, you will be notified right on sunset.


I’m surprised @WCmore didn’t point out you will also want to change you time check to

time is NOT between sunrise and sunset.

While this is technically the same as your condition, bridging across midnight can cause issues with the definition of sunrise/sunset.


Thanks for all the help!

Does this look reasonable?


@spdctrl Looks good!




Great, thanks again everyone! :slight_smile: