Rule Engine - Killing a Previously Running Iteration

I am looking for a Rule Engine technique where I want to extend a timer event. Probably easier to give an example.

I have a rule that tells a light to turn one for an hour when a door is opened. Simple enough . . trigger the light on on the door sensor opening, delay for 1 hour, turn the light off. Now if I open the door 15 minutes after the first time, I’d like that light to remain on from an hour after the door is opened the 2nd time.

But in this example, the first iteration will still be running and the light will turn off 60 minutes from the first opening, not the second. Ideally, killing the first iteration would solve the issue but I don’t think that’s possible. I considered variables, but I think that would take a time type.

My example is simplified. There are multiple triggers, so watching for an event to trigger the turn off won’t work in this case.

Any ideas?

Thanks!

How about adding an IF condition in the flow after the delay and before turning off the light to check if the door has stayed closed for 60 minutes before turning off the light? See below for the rule to your example that if the door is opened again during the 60 minutes when first triggered, the first triggered rule will basically skip the turn_off action.

1 Like

Thanks, that may do it. I’m actually doing that for another door routine and that has been working well. I’ll give that a go. Thanks!

1 Like

This works, although I have found that the pause needs to be longer than the “stay closed” value. I’ve experienced some issues with SmartThings and Rule Engine not getting status as quickly as I would have expected. I added 3 minutes to the pause over the “stay closed” value to solve the issue. Not sure it has to be that long, but this isn’t critical so I’ll leave it alone.

Thanks for the update. Would be interested to know if you run into the stale state issue again and how does the rule log’s runtime data look like against to the SmartThings’ device state history. (So glad that we have the rule log feature now. :joy:)

Hi James,

It’s continuing to run ok using the virtual switch instead of the mode. There is a thread in the SmartThings forum where people were complaining of mode issues. Not exactly on point, but close enough.

Based on my experience of the rule running a few minutes after it failed, my guess is that the issue resulted in a failure to expose the mode change in a timely manner.

Gonna call it good. Thanks for your help!

Bry

https://community.smartthings.com/t/smart-lighting-location-mode-automations-not-running-oct-2021/232426

2 Likes