Continuing combination motion plus door sensor. Edited to entity from device

Continuing the discussion from Automation lights based on motion or door sensor will not not work:

Ok here is YMAL reworked as entity instead of device, so it’s easier to follow along. I can get the automation to work for light switch to turn on if door is opened as an automation and I can get lights to work based on motion as separate automation. If I combine with “or” to give option to turn on lights based on motion or a door opening the motion portion will not trigger lights in this instance. What am I missing?


alias: "Laundry Room door switch "
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.laundry_room_door_window_door_is_open
    from: "off"
    to: "on"
  - trigger: state
    entity_id:
      - binary_sensor.laundry_room_motion_motion_detection
    from: "off"
    to: "on"
  - trigger: state
    entity_id:
      - binary_sensor.laundry_room_motion_motion_detection
    from: "on"
    to: "off"
    for:
      hours: 0
      minutes: 5
      seconds: 0
conditions: []
actions:
  - if:
      - condition: state
        entity_id: binary_sensor.laundry_room_door_window_door_is_open
        state: "on"
      - condition: or
        conditions:
          - condition: state
            entity_id: binary_sensor.laundry_room_motion_motion_detection
            state: "on"
    then:
      - action: switch.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: switch.wave_1
    else:
      - action: switch.turn_off
        metadata: {}
        data: {}
        target:
          entity_id: switch.wave_1
mode: single

type or paste code here

There’s an issue in the Or condition. The conditions both need to be nested under the Or. As shown, it is the same as a series of two conditions… which are logically AND.

...
actions:
  - if:
      - condition: or
        conditions:
          - condition: state
            entity_id: binary_sensor.laundry_room_door_window_door_is_open
            state: "on"
          - condition: state
            entity_id: binary_sensor.laundry_room_motion_motion_detection
            state: "on"
....
A slightly different way using trigger ids
alias: "Laundry Room door switch "
description: ""
triggers:
  - id: "on"
    trigger: state
    entity_id:
      - binary_sensor.laundry_room_door_window_door_is_open
      - binary_sensor.laundry_room_motion_motion_detection
    from: "off"
    to: "on"
  - id: "off"
    trigger: state
    entity_id:
      - binary_sensor.laundry_room_motion_motion_detection
    from: "on"
    to: "off"
    for: "00:05:00"
conditions: []
actions:
  - if:
      - condition: trigger
        id: "on"
    then:
      - action: switch.turn_on
        target:
          entity_id: switch.wave_1
    else:
      - action: switch.turn_off
        target:
          entity_id: switch.wave_1
mode: single

Thanks for the help. I really appreciate it.