Trigger automation during time period if condition is met AND has been met for XXX amount of time

TL;DR

Trigger condition during time period if condition is met AND has been met for XXX amount of time.

Full Scenario

I have my garage door connected to SmartThings. I would like to set up an automation to close it automatically, if the following conditions are met:

  • Time is between 9:00PM - 7:00AM
  • Garage door is open
  • Garage door has been open for at least 15 min.

It would also be nice (but not required) that if the garage door fails to close (sensor doesn’t go back to “closed” status), it doesn’t attempt to do it again, but if it opens after it has been closed, that it would trigger again after 15 min.

The time and garage door status are trivial, but I don’t know how to do the third condition (or if it’s even possible).

It can’t currently be done with the official features, but there are several alternative methods. See the community FAQ:

FAQ: Get a Notification if Something is Left On, Open, or Unlocked for X Minutes (2020)

1 Like

I knew there had to be some way to do it, missed the FAQ. I’m a SharpTools user, so will likely try going down that route.

Thanks!

2 Likes

Thanks again for the pointer, @JDRoberts! I ended up using SharpTools and creating two rules for this, one with each of the following triggers:

  • At 9:00PM, if the garage door has been open >= 15 min.
  • Garage door has been open >= 15 min., if time is 9:00P-7:00A.

The action for each rule is the same:

  • Close garage door.
  • Notify me via pushover.

One thing I wish I could do is create actions independently of my rules, and then have multiple rules call the same action, so I could do any future edits to my actions in one place.

Thanks for the pointer - I knew there had to be an easy answer, and it doesn’t get much easier than that.

2 Likes

@DarthBob, nice rules. Just wanted to make sure you used “OR” condition logic for the 9:00PM - 7:00AM, since it is considered as the next day after the midnight.

Having the rule to call another rule is a cool idea, and there’s already an open feature request in SharpTools community for it. So you may want to vote your interests there.

2 Likes

Thanks. I actually used the “between” condition for my rule:

This appears to satisfy the condition:

I must admit that I’ve only tested it in the evening, however, never after midnight. I may have to test this tomorrow morning when I get up to let the dog out.

That is a cool idea (and using a virtual switch to trigger it with a momentary press is an excellent idea), however that’s not quite what I was thinking.

I’m a long-time Tasker user in Android, and with Tasker, you can create tasks to be executed and save them independently of a specific workflow, IIRC. At that point, the task is available to be called by any rule. I.e., I could create a task to close the door and notify me via pushover, then wrap that inside each of the if statements. Now that I’m actually describing it, though, this is basically the same thing as creating a rule without a trigger, which IIRC SharpTools already allows. So maybe I just didn’t think this through enough. :grin:

1 Like

Tested it early this morning, when I got up to let the dog out. The between condition functioned as expected: It waited 15 min., then closed the garage door and notified me.

I also moved my action to a separate rule, triggered by a virtual momentary button press in SharpTools from the first rules. Again, it functioned as expected. Not quite as easy as calling a rule from a rule (I had to create a virtual device as a trigger), but it worked well enough.

3 Likes

Thanks for the screenshot, and yes the between option will work as you desired. Was just thinking if you used before and after approach.

Yes, this would work, and I agree that allowing the SharpTools rule to execute another rule directly would be an easier option, and thanks for voting. :+1:

2 Likes