Overlapping motion sensor/light configuration

Hi,

So I have the following situation.

Motion sensor A triggers lights 1, 2 and 3 and switches them off after 15 minutes
Motion sensor B triggers lights 3, 4 and 5 and switches them off after 15 minutes

Say motion sensor A triggers first and after 5 minutes motion sensor B triggers.
I would like for light 3 to remain on until the timer of motion sensor B expires and not to be switched off after A expires.

I would look something like “If A or B then 3 is on, else 3 is off”.

Does anyone know how this can be implemented?

Do your motion sensors turn off after 15 minutes after being turned on or do your motions sensors turn off immediately and you just have a delay step in an automation?

  1. If your motion sensors turn on for 15 minutes minimum and only turn off only after 15 minutes of inactivity then create a binary sensor group and add those two motion sensors to it. The group will turn on when either is on and only turn off when both are off.

  2. If your motion sensors turn off shortly after detecting motion and you’ve been relying on 15 minute delay steps then create a trigger template sensor like this:

template:
  - trigger:
    - platform: state
      entity_id:
        - binary_sensor.motion_sensor_1
        - binary_sensor.motion_sensor_2
          ...
      to: 'on'
    binary_sensor:
      name: Grouped motion sensor
      state: 'on'
      auto_off: '00:15:00'
      device_class: motion

This will turn on when either of the motion sensors detects motion and then turn off if its been 15 minutes since one detected motion.

Then remove all the delay steps and references to the motion sensors in your automation and instead just have it trigger off the grouped one you made in #1 or #2 above. Turn the light on when it turns on, turn the light off when it turns off.

1 Like

Thanks a lot, this will do the trick. It is as situation 2 you mentioned. I figured this would allow me to have full flexibility over the auto off time.
I do have two follow up questions, if you don’t mind.

  1. Will the timer be reset if either one of the motions sensors is triggered again during the 15 minutes on time?
  2. I would also like to make a button the app which will allow me to override the motion sensors and control the lights manually (thus no auto off time). Is this also possible?

Yes. Every time one of those triggers fires the state will be re-calculated and the auto_off timer will reset.

Definitely. But this is something I would do in the automation. There’s a few ways to do it, depends on what you want and your setup.

Do you have one automation that turns on and off the light from the motion sensor? If so you actually don’t need to make anything else at all. If you include an automation in a dashboard it shows a toggle to enable/disable it. If you disable it then the motion sensor will keep doing its thing recording motion but the light will remain in whatever state it was in until the automation is manually enabled again.

If you have one automation that controls multiple lights each from their own motion sensors then you probably want an override button per light. In that case I would make a toggle helper per light/room you want to be able to override. And then in your automation before turning the light on or off check its corresponding helper. If it’s on proceed, if not then do nothing.

Both of these involve you manually turning on an override and then turning it off again later. You may want your override to time out however, like maybe resume automated light changes after 2 hours. In that case an easy option could be to use a timer as your override. Start the timer to override the lights, cancel it to end the override early. Your automation will work basically identically to what I described above except its checking to see if a timer entity is idle or not instead of checking if an input_boolean entity is on or not before adjusting the lights.

You can obviously get much much fancier with this if you want (as with everything in HA). For instance I wanted to use the light switches already on my walls as my “override button” rather then having people go into HA to override the automation. I laid out my approach for doing something like this here:

Up to you how far into this particular rabbit hole you want to go :slightly_smiling_face:

Thanks for your help. I can make it work using this information.

I have one additional comment to this. Does your motion sensor remain ‘on’ when continutous motion is detected? That often is the case. If so, you should start the off timer after motion stops, not when motion starts. It could otherwise be that when you move continuously for over 15 minutes, lights will turn off regardless. This effect is most obvious if the delay is short.

The motion sensors have a pulse output of approximately 1 second when set a the lowest possible delay time. That is, they will switch off regardless on whether there is motion. After a pulse it is not able to switch for at least 20 seconds or so.
If I set some delay other then the pulse it remains on as long as there is motion, but I think the pulse is the way to go here.

Hello Dear

how to activate the template & link it to one light? or this will work automatically with the pre-configured Automation created?