Event Stacking

Now that I have a camera that provides reliable in-camera person and vehicle motion detection (Unifi G4 Instant vs Wyze Cam anything). Light Activation with HA works great:

My question is:

What is the expected behavior when motion events stack-up?

  1. Motion → lights on → 10 minutes later, lights off.
    or
  2. Motion → lights on → 10 minutes after last detected motion, lights off.

Or said another way: How does the processing queue stack-up when additional motion events occur within the 10 minute lights-on window?

Correct me if I am wrong but I believe you are asking what happens if an automation that’s busy, processing its actions, is triggered again.

The answer is: It depends on the value of its mode option.

  • single ignores subsequent triggers and finishes processing its actions.
  • queued will process subsequent triggers after it finishes processing its actions.
  • restart aborts processing its current actions and restarts processing them.
  • parallel continues processing its actions and starts processing a duplicate set of actions.

Reference: Script Modes

The default value of mode is single. If the automation is triggered while it’s busy, the trigger is ignored and a warning message is also reported in the Log. This message can be suppressed by setting max_exceeded to silent

1 Like

For example, if your automation were to use restart mode, if it was re-triggered while processing its delay it would exit the delay immediately (i.e. it won’t wait for thedelay to finish and it won’t turn off Front Outside light) then execute its three actions again:

  1. Turn on the Front Outside light
  2. Start the 10 minute delay
  3. Turn off the Front Outside light
1 Like

Besides what happens when additional motion events come in during the 10 minutes, there’s also the behavior of the particular motion sensor. Some motion sensors keep the motion detected state on when additional motion is detected. In that case there’s no additional motion event, even though there’s still motion. So starting the timeout when motion stops is imho always the best course of action with the most predictable outcome. And of course canceling the timeout when new motion is detected.

1 Like

@123 That’s exactly what I was asking. I had remembered “mode” at the top of the automation definition in the past, now that it is hidden away behind the 3 vertical dots, I forgot about it. “restart” is the mode I was looking for. :wink:

@Edwin_D Two separate automations:

  1. Motion on → Lights on
  2. Motion off → Time Delay, Lights off

could have advantages.

My use case: When I open the door at night to walk the dog, the outside light turns on without me reaching for the switch :wink:

I’ll keep it to the one automation for now and see what sort of feedback I get from my user community.

THANKS!!

1 Like