Turn on lights when door is open if it's been closed for x hours?

If a door is opened, I want to turn on the room lights if the door had been closed for x hours or longer. I have a webCore piston that does this very easily and nicely for a long time. However with webCore on its way out, I need a way to replicate this in ST.

I tried to create a routine, but it won’t let me do what I want. For instance, for the routine IF clause, I select IF door-switch is OPEN and that part is ok so far. But then I need to say “AND door has been closed for x+ hours” THEN, and its this second part I don’t know how to do.

Any ideas? Thank you.

Use 2 routines.

One routine would operate a virtual switch after the door has been open for x hours. It would need some sort of automatic reset.

Then use that virtual switch in you main routine as one of the conditions.

I can see how that would work, thanks. Although I think that is a pretty cludgy way to have to do it. Imagine more complex rules, and several dozen automations. There could be possibly hundreds of switches needed for everything. Is there another way? This is where webCore shined. Is there some sort of programming language alternative coming to replace the functionality what webCore provided?

Maybe. :thinking:

There is a new official rules API, but it is still in development.

Their equivalent of Pistons are called “recipes.“

Routines are just very simple guided automations built into the app. They are what they are.

The underlying engine is the Rules API and that is the place to go for more complex automations. It has a way to go to match webCoRE capabilities, if that remains an objective, but it is a lot more powerful than Routines.

1 Like

I know it is not the same, but have you considered using the time as precondition ?
Your automation probably works once a day.