3 level staircase with 3 presence detectors - how to configure?

Hi I’ve got a staircase going up 2 storeys. I’ve installed Tuya presence detectors on each floor that activate the stair lighting when triggered. They also turn off the lighting when they are untriggered (including a few seconds to allow you to finish going up or down the stairs).

So each motion sensor has two automations. 1 to turn on the light when triggered and 2 to turn off the light when no presence is detected.

But …… 2 people using the staircase doesn’t work properly as the 1st persons detriggeirng the sensor when they moved out of range means the lights can turn off even though someone just triggered the sensor on another level to turn the lights on.

Any ideas on how I should be configuring these sensors to work together a bit better ? Thanks

Make the turn off automation need all three sensors to be off at the same time before the lights are turned off.

1 Like

I use this automation to turn on and off the bar lights in the basement. The room is large that one motion sensor was not enough. This has worked for me for ~2 years.

- id: 'Bar Lights On and Off based on motion and switch'
  alias: Bar Lights - Turn on and off based on stairwell light.
  description: Turn on and off all the lights in the bar area
  trigger:
    - id: 'bar_on'
      platform: state
      entity_id: binary_sensor.bar_stairwell_motion_sensor_motion
      from: 'off'
      to: 'on'
    - id: 'bar_on'
      platform: state
      entity_id: binary_sensor.shellymotionsensor_60a42395fc6a_motion
      from: 'off'
      to: 'on'
    - id: 'bar_on'
      platform: state
      entity_id: binary_sensor.bar_main_motion_sensor_motion
      from: 'off'
      to: 'on'
    - id: 'bar_on'
      platform: state
      entity_id: binary_sensor.bar_ne_corner_motion
      from: 'off'
      to: 'on'
    - id: 'bar_on'
      platform: state
      entity_id: switch.stairwell_light
      from: 'off'
      to: 'on'
    - id: 'bar_off1'
      platform: state
      entity_id: binary_sensor.bar_ne_corner_motion
      from: 'on'
      to: 'off'
      for: '00:01:30'
    - id: 'bar_off1'
      platform: state
      entity_id: binary_sensor.bar_main_motion_sensor_motion
      from: 'on'
      to: 'off'
      for: '00:01:30'
    - id: 'bar_off'
      platform: state
      entity_id: switch.stairwell_light
      from: 'on'
      to: 'off'
    - id: 'bar_off1'
      platform: state
      entity_id: binary_sensor.bar_stairwell_motion_sensor_motion
      from: 'on'
      to: 'off'
      for: '00:01:30'
    - id: 'bar_off1'
      platform: state
      entity_id: binary_sensor.shellymotionsensor_60a42395fc6a_motion
      from: 'on'
      to: 'off'
      for: '00:01:30'  
    - id: 'bar_off1'
      platform: state
      entity_id: binary_sensor.bar_ne_corner_motion
      from: 'on'
      to: 'off'
      for: '00:01:30' 
    - id: 'bar_off1'
      platform: state
      entity_id: binary_sensor.bar_main_motion_sensor_motion
      from: 'on'
      to: 'off'
      for: '00:01:30'
  condition: []
  action:
  - choose:
    - conditions:
        - "{{ trigger.id == 'bar_on' }}"
      sequence:
        - service: switch.turn_on
          target:
            entity_id:
            - switch.stairwell_light
            - switch.bar_pool_table_light
            - switch.rope_lights
            - switch.bar_hall_to_media
            - switch.bar_landing
            - switch.area_cans
        - service: light.turn_on
          target:
            entity_id:
            - light.bar_pendant_light
            - light.bar_back_bar_cans
          data:
            brightness_pct: 50
    - conditions:
        - "{{ trigger.id == 'bar_off' }}"
      sequence:
        - service: switch.turn_off
          target:
            entity_id:
            - switch.area_cans
            - switch.bar_pool_table_light
            - switch.rope_lights
            - switch.bar_hall_to_media
            - switch.bar_landing
            - switch.stairwell_light
        - service: light.turn_off
          target:
            entity_id:
            - light.bar_back_bar_cans
            - light.bar_pendant_light
    - conditions:
        - "{{ trigger.id == 'bar_off1' }}"
        - "{{ states('binary_sensor.bar_main_motion_sensor_motion') == 'off' }}"
        - "{{ states('binary_sensor.shellymotionsensor_60a42395fc6a_motion') == 'off' }}"
        - "{{ states('binary_sensor.bar_ne_corner_motion') == 'off' }}" 
        - "{{ states('binary_sensor.bar_stairwell_motion_sensor_motion') == 'off' }}"
      sequence:
        - service: switch.turn_off
          target:
            entity_id:
            - switch.area_cans
            - switch.bar_pool_table_light
            - switch.rope_lights
            - switch.bar_hall_to_media
            - switch.bar_landing
            - switch.stairwell_light
        - service: light.turn_off
          target:
            entity_id:
            - light.bar_back_bar_cans
            - light.bar_pendant_light
    default: []
  mode: queued

Hope this helps you

1 Like

Thanks for sharing.

A lot to digest here as I haven’t done much in YAML.

Is there a way to create an automation of sensor1 OR sensor2 detects turn on a light? It seems if I add multiple triggers they are AND ie sensor1 AND sensor2 both need to trigger for the automation to execute.

That is not so, triggers are independent. Maybe post your automation?

Thanks. That worked. I couldn’t get the “On” automation to work in HA as there are 3 triggers (1 for each sensor) and it seems they all need to be triggered.

But that does work rather nicely for the “off” automation configured as you suggested.

Triggers are OR’d. If you need And then confirm all the trigger states in the condition of the automation.

1 Like

Yep !!! Got my logic totally back to front there. Seems to all be working as needed now. Thanks :pray:

Only issue is since moving the automations from Smart Life to HA there is a noticeable lag and it’s easy to reach the stairs before the light comes on. Will have a play with the sensor detection distance and sensitivity and see if that can improve matters.

1 Like