I came across this page from a web search and thought I might offer another Google Calendar solution. In contrast to Dan's solution, this method offers more granular control than his hour-by-hour delays of time zone hackery.
In this example, I have a Ring doorbell. When it detects motion, it triggers IFTTT to turn on my porch and flood lights. A few minutes later, a Google calendar event's ending prompts IFTTT to turn the lights off. Here's the recipe:
- Log into https://calendar.google.com/ . Create a new calendar separate from your primary. Mine is named Doorbell. Set it to your proper time zone.
- In IFTTT, create the following applets:
- If motion is detected, then turn on the lights.
- If motion is detected, then Quick Add an event to the Doorbell calendar. The quick add text reads "motion detected
CreatedAt + 15 minutes".
CreatedAt is inserted as an ingredient from the drop-down menu adjacent to the text entry.
- If an event ends on the Google calendar named "Doorbell", turn off the lights.
The secret sauce is how the Google Calendar Quick Add event text is phrased.
CreatedAt added via the ingredients drop-down list sets the beginning of the calendar appointment to the time the motion is detected.
+ 15 minutes sets the duration. Since it's the end of the appointment that IFTTT monitors, this determines the timing.
The timing of execution isn't exact. IFTTT documents a +/- 15-minute window for firing an action triggered by the end of a Google Calendar event. In my experimentation this evening, the lights are turning off about 5 - 7 minutes early, and there was about a minute difference between the two lights when I didn't link them in a scene. It's close enough for government work as-is though. If you want your lights to stay on for about 10 minutes, then use
+ 15 minutes in your quick add text.