Occupancy routine triggered too much, lights stay on

I have a routine in a bathroom where if it’s after sunset and a SmartThings Motion Sensor detects motion and the light is Off, then the light turns on. (It’s a Lutron Caseta wireless dimmer.)

While I am in the room, I want to turn the light off. I turn the light off and try to walk out the door, but my routine immediately detects that the light is off while motion is happening, so it immediately turns the light back on!

What’s the way to fix this?

I thought I could delay the execution of the occupancy routine multiple times by adding a delay of 15 minutes at the end of the routine, with or without a following action (send me a blank notice). When there is no following action, ST deletes the delay. When there is a following action, (I think) the following action occurs but it doesn’t stop the routine from triggering multiple times overlapping, so that doesn’t solve the problem.

I think the desired behavior is if the room becomes occupied and the light turns on automatically, and then someone turns off the light while inside the room, it should stay off for X minutes (let’s say 15 minutes) and not trigger the occupancy routine again, Or, it should stay off until the room is considered “vacant”, I.e., the motion sensor doesn’t detect any motion for Y minutes (let’s say 10 minutes).

First things first. Why is this happening?

If you set the condition that tests for the light being off as a ‘precondition’ the Routine should only be triggered by the motion changing between inactive and active.

If you have already done that then the motion sensor would have to be going inactive and active again while you are in the room, which it may well be, and you’d have to catch it at the ‘wrong’ point in its cycle every time. So I’d be looking at how well the motion detection is working for you.

I am struggling to think of an automation only solution that doesn’t involve a timer of some sort as a fallback.

My observation is that it is happening because there are two preconditions, and SmartThings evaluates the routine every time any precondition changes.

Specifically: the motion sensor has a “reasonable” timeout of a few seconds, I believe it’s about 3 seconds. I am in the room moving, or I am at the edge of the room about to leave. Motion is detected and stays in the detected state. However, when I press the off button on the dimmer switch, the precondition Light state changes from On to Off. This causes SmartThings to evaluate the routine, which means it checks the motion sensor and it is On (even though the motion sensor did not change state at the time), so it runs the routine.

To make matters slightly worse, my Lutron Caseta Wireless dimmer switch reports to Lutron that it is switched to “off” right at the beginning of the button press, even though the dimmer will gracefully dim the light over the course of about one second. If the dimmer switch didn’t report “off” until after it auto-dimmed all the way to zero, I would have one second to leave the room which might be enough time (in theory) for the motion sensor to return to its off state. However, this would not solve the other case, which is when someone remains in the bathroom and intentionally wants the lights to be off.

Oops, didn’t realise I’d already posted the reply. Been editing away for ages …

That’s pretty much the opposite of what should be happening. The preconditions are prequisites for the things to happen but they shouldn’t make things happen in themselves. Only the devices in the actual conditions should matter and that should just be the motion sensor.

I suppose there is the possibility that the motion sensor integration has set the state change flag true so repeated motion active events are being propagated, though that is rather unusual.

Well, based on observed behavior I’m seeing that the light change sets the state change flag to true…

so how to get out of this mess?

Maybe with this one:

You need to add a virtual motion sensor (virtual switch) which will turn on when motion is detected.

The virtual motion sensor will turn off (no motion) under the following conditions:

Virtual motion sensor turn on is used to control the light on.

Ok and where is the driver for this virtual motion sensor :slight_smile:

You can use @TAustin vEdge driver

Another possible solution.
Create a virtual switch say “override switch”.

If you turn the lights off *while motion is detected “ then have routine
1 turn on override switch
2 Wait for dwell time for sensor to become unoccupied + buffer time to leave room
3 Turn off override switch

Also change routine to switch light on when motion detected to only turn them on when override switch is off

Example if the time to detect absence is 40 seconds and the buffer time to exit room is 15 seconds then set the overall delay to 55 seconds.

Of course this means if you exit the room and instantly return the lights won’t come on for 55 seconds

1 Like

Thanks @Declankh.

I cobbled together a solution using the Virtual Scene Switcher device. The device has two scenes: 1 (normal) and 2 (occupancy triggered). Logically it appears to work exactly as @Declankh says with the override switch. I set the dwell time to 15 minutes, or to 10 minutes following continuous vacancy. The Aeotec/Samsung SmartThings Motion Sensor that is part of this setup appears to reset motion detection after 15 seconds.

I haven’t scrutinized the behavior of commercially manufactured occupancy sensors in the past like this. Has anyone else? My guess is that the occupancy sensor simply stays in “motion detected” state for an industry-standard length of time.

The dwell time, how long the sensor takes to register no motion or presence after there is no motion or presence detected varies wildly depending on the device. The old tradfri motion sensors take 3 minutes, the newer ikea are about 20 seconds, aeotec around 40 seconds. There’s no set pattern and for battery powered devices it’s often a battery saving strategy.
On my lafaer presence sensor it’s configurable with shortest time of 20 seconds