How do i reset the counting in routines?

I have quite some routines that have lights in them that turn off after x amount of time has passed without movement. However, if for example 2 minutes have passed of no movement and the the lights turn off, i can still turn them on with alexa or manually- and then they will not turn off anymore until the motion sensors first detects movement and then starts counting towards no movement again.
Is there a way to improve this?

I always have separate routines, one (or sometimes more) to turn lights on under various conditions, and another that simply turns them off after no movement.

But how do i make the countdown start after lights are turned on? That smartthings does not keep counting forever until movement is detected, but starts counting when the lights turn on.
Probably only can be done with some complicated virtual switches then.

IF movement detected THEN turn on
IF movement not detected for 2 minutes THEN turn off

If you always want to turn light off after 2 min you can add this routine

yes, the problem is that smartthings is coded to start counting from the moment no movement is detected.
So if i turn on the lights with alexa or manually, or with a other routine, without the motion sensor, and the motion sensor has already not detected movement for 2 minutes, the lights will NEVER turn off from the routine that turns them off after 2 minutes of no movement, because it is already longer then 2 minutes of no motion detected.

Currently I am thinking it’s probably better to start counting from the moment the lights were activated that were attached to the routine that disabled them if no motion is detected.
So: If lights are activated → Start recounting the “no motion detected”.

Here’s an example of what I do, though I realise now that it doesn’t address your exact use case. If there is no movement for 5 minutes, then nobody is there and the lights go off, nothing more complex than that, and I’ve never noticed any issues.

This works even if people switch on lights with a Hue switch, to set a scene perhaps, or use Google Assistant.

Edit: turns out that doesn’t work, I too now realise that if the lights are turned on by any means other than a routine involving the motion sensor, the “off” routine won’t work until movement restarts the countdown.

you mean the first routine works, even if that same sensor did not detect movement for 10 minutes, and on the 6th minute of no movement you turned on the lights manually?

That is not the case in my house, maybe it’s dependant on driver/devices then…hmm…

1 Like

I believe so, yes. I’m curious though, perhaps I have a potential issue but never encountered it. I’ll do a check and respond back with an edit here later…

Edit: It turns out I was wrong as I see the same issue you do after the test below:

  • The “On” routine turns light on when motion detected
  • The “Off” routine turns light off after no motion for 1 minute - works fine
  • I turn light on manually
  • The “Off” routine does not trigger - i.e. same as your issue, the time counter has not reset
  • I move past the motion sensor
  • The “Off” routine now turns the light off after 1 minute - the time counter had been reset

I now understand what you mean. Apologies for my earlier suggestion, I’ll add an edit to correct.

Now I’m also curious as to the best answer to your question!

Answering your question, you can’t reset the counter from the THEN clause without re-triggering the IF clause.

I think these routines below are the best you can do with the current ST limitations…

A: Switch
B: Motion sensor

IF during night (pre-condition) AND B:movement detected THEN A:turn on
IF A:turned on (pre-condition) AND B:movement not detected for 2 minutes THEN A:turn off
IF B:movement not detected (pre-condition) AND A:turned on for <max> minutes THEN A:turn off

<max>: maximum acceptable interval to keep the light turned on (Something like 30 minutes or even more)

Particularly, I don’t see a reason to ask Alexa to turn on a light of an area that you won’t use it, mainly if you already have a motion sensor to control it, but that is subject for another discussion.

Eventually, you will understand motion sensor is not good enough for controlling light state.

2 Likes