Help with a routine IF statement

I’m in the process of recreating my routines in the SmartThings app. Previously, I used SharpTools.

This morning, I created a routine to turn on certain lights when I return home after sunset. Odd thing happened. I had already been home for a couple of hours, and when sunset came, the lights turned on. I only want this to happen when I’m returning Home after being away. My IF statement must be incorrect.

Here’s what I’m currently using.
10 minutes after sunset - Every day
Member location
Who - Me
Where - Home
When - At Home
Advanced options
After being away how long - enabled
10 minutes

You want a time range, not specific time. Set it to time range sunset to sunrise.

1 Like

it will still have the same effect if the user is home before the set time…correct?

Thanks, I’ll give that a try. Is the after 10 minutes away necessary, or does it work the way I want it to without it?

no because time range is always a precondition, so it can’t trigger the routine.

it is why I like motion sensors :wink:

1 Like

Can I set a time range from sunset to 11:30 PM?

Not in a Routine. To track state for a relative time and a specific time, use a virtual switch to represent the time range. Then use that virtual switch being on as a precondition in your Routine. Set your virtual switch to come on at sunset and go off at 11:30 pm.

1 Like

The ‘after 10 minutes away’ is really about de-bouncing. It was introduced at a time when a number of users found their phones would switch to present when arriving home, immediately switch back to not-present, then switch to present again a couple of minutes later. Of course it also has other applications beyond that.

The ‘gotcha’ you encountered is that even if you haven’t left the house for a long period of time but the last time you did it was for more than ten minutes the condition remains true. However you only hit it because you were actually running the Routine at a certain time and the changes suggested were to make sure it was your presence changing that was triggering the Routine.

Whether you need to use the ‘after 10 minutes away’ really depends on your circumstances. In our case we effectively get ‘after 5 minutes away’ by default because if anyone returns quicker than that they were probably never considered away to start with.

1 Like