Wait_for_trigger not working for motion sensor

Hello,

I tried to use the wait_for_trigger to combine two automation into one.
I had one automation to turn on light when motion detected and another automation to turn off lights when no motion detected. They went well.

However, I tried to combine them into one automation and the new automation doesn’t work.

Here is my automation.

- id: '123456789'
  alias: living room light
  description: ''
  trigger:
  - device_id: 1234abcde
    domain: binary_sensor
    entity_id: binary_sensor.samsung_motion1_ias_zone
    platform: device
    type: motion
  condition:
  - condition: state
    entity_id: input_boolean.living_light_off
    state: 'off'
  action:
  - device_id: 456789
    domain: switch
    entity_id: switch.plug6
    type: turn_on
  - brightness_pct: 100
    device_id: 789456
    domain: light
    entity_id: light.osram_lightify_a19_on_off_dim_e8c50c00_level_on_off
    type: turn_on
  - wait_for_trigger:
    - type: no_motion
      platform: device
      device_id: 1234abcde
      entity_id: binary_sensor.samsung_motion1_ias_zone
      domain: binary_sensor
      for:
        hours: 0
        minutes: 2
        seconds: 0
    timeout: ''
  - type: turn_off
    device_id: 456789
    entity_id: switch.plug6
    domain: switch
  - type: turn_off
    device_id: 789456
    entity_id: light.osram_lightify_a19_on_off_dim_e8c50c00_level_on_off
    domain: light
  mode: single

Does this not work ?

  - wait_for_trigger:
      - platform: state
        entity_id: binary_sensor.samsung_motion1_ias_zone
        to: 'off'
        for:
          minutes: 2

Yes, this works!
But I have no idea why my previous setting didn’t work. I suspect the new wait_for_trigger has some bugs.
1, my previous automation doesn’t look incorrect, and another automation using exactly the same writing (just different sensor and different light) can work.
2. the solution you posted can work, but lights are turned off by “service.light.turn_on”. It used to be “service.light.turn_off” if in a separate automation.

I figured out why.
It seems that you cannot have timeout '' in automation, that will stop everything after the wait_for_trigger.
Somehow the automation GUI editor had it inserted automatically, you have to manually delete it from YAML editor or just fill something in timeout and delete it.