Bug: Motion Sensor vs. timespan

The dog needed to step outside early today, and we discovered a new bug - not of the garden variety.

Motion sensor instances in ST offer a builtin routine to turn lights on triggered by motion and back off after X amount of time. The routine can also be limited to a certain timespan, like from sunset to sunrise.

Now today we happened to trigger the motion sensor very shortly before sunrise, and coming back from the dog’s business we found the lights were still on.

What happened?

Apparently, when this kind of routine triggers right before its timespan ends, the “turn lights back off” part of it falls outside of the timespan and never gets executed. The light stays on.

2 Likes

This is probably a feature of SmartThings.

You need to add a backup routine that runs after sunrise..

Didn’t know there was an option there to create the automation, I usually create two routines:

  • One to turn on with the given time period.
  • One to turn off with the given time period PLUS an extra time, precisely to avoid that edge case scenario of turning on near the end and the off falling outside the period.

I’ve checked the Rule created by the inbuilt option and the start and end times are the same for on and off so, yeah, it won’t run if the off has to happen few minutes after the end.

I’d consider it a bug, maybe they could tweak the rule to shift the period by the “no motion” time specified. E.g. if the on rule condition is between 7:00 and 10:00 with a no motion time of 5 minutes, make the condition for off between 7:00 and 10:06 for instance.

Exactly, that’s what needs doing, and it’s probably a broader problem. When a routine triggers right at the end of its time period, this routine itself and also its dependencies must be allowed to complete even if that completion falls past the end of the period.

My routine actually uses the minimum time of 10 seconds*, and even with that it’s still possible to exactly hit the edge of the timespan such that “On” is still within and “Off” falls outside and therefore never happens.

*(Why just ten seconds? The motion sensor - IKEA’s MYGGSPRAY - has its own timeout before it reports “no more motion”, so it’s more like half a minute not ten seconds total.)

EDIT: Just for clarity: The bug is in how the routines are generated, not in how they execute. This builtin thing actually generates two routines, one for On and another for Off, both with the same time period. The “Off” part would need the end of the time period extended, and not just by the user selected delay, but considering inherent device delays too.

Also workarounds - I’ll add a “turn off at sunrise” to the lamp.

1 Like

I don’t see it as a bug so much as a feature you have to be aware of with motion lighting. Yes, you can mitigate the issue with extensions to the active ‘off’ period, or turning the light off after a period of time, or at a fixed time, but all may be imperfect or undesirable in practice.

I have settled on just extending the ‘off’ period and taking the hit on lights still being left on occasionally, mostly only at certain times of year. I found that the alternative of turning them off on a timer had the potential to do more harm than good.

It seems rather unwise to include motion routines as a standard feature, particularly ones that can turn off lights, as they just don’t know how they will be misused.

I have doubts, that routines are not executed, for example, when the hub installs a new driver version. This doubt concerns the v3 hub.

What happens to the routines containing the timer when the hub performs a new firmware update?

Hi, @Peter-M
Do you still have the original routine configuration?
I’d like to take a look and to ask the engineering team about this to clarify the expected behavior.
Please, provide the routine’s name. Also, share a screenshot of how it looks in the app to compare how it’s “translated”.

Hi nayelyz,

thanks for caring, here’s the data. My account is open for access, you have the details.

The motion sensor is “Bewegung Windfang”, the lamp is “Lampe Windfang”.

The routine is as original as it gets, including its default name “Bewegung Windfang, bei Erkennung Licht einschalten” - as mentioned, using the motion sensor device’s integrated routines feature. As you see in the 3rd screenshot below, this actually creates two rules, one for On and one for Off.

For the workaround I did not modify this, instead I added an “off at sunrise” to the lamp, also from device integrated routines. This routine auto-named to “Lampe Windfang, Ausschalten”.

Epilogue: I had to adjust my workaround.

At sunrise: Turn [lamp] off

actually executes at [minute of sunrise +0s], while the sensor routine stays hot through [minute of sunrise +59s] - so if you trigger the sensor exactly during this minute, the lamp never turns off.

So, improved workaround

At sunrise+1m: Turn [lamp] off

Hi, @Peter-M
Thank you for sharing your workaround.
The engineering team hasn’t provided any feedback yet. We’ll ping them again. Our goal is to determine whether it should work this way or if it’s a bug.