Automation, wait template

I’m trying to create an automaton that only activates if 2 things happen within 5 seconds of one another. I cobbled this together, but not even sure if a wait template is the best way to go about it. What I have done is definitely not working. Please help me get this going.

alias: Entryway - Drfit - Turn on when someone comes in
description: ""
trigger:
  - type: motion
    platform: device
    device_id: cfa0e90b69ef4be6786ddce92fbc3d08
    entity_id: binary_sensor.front_doorbell_motion
    domain: binary_sensor
condition:
  - condition: template
    value_template: >-
      wait_template: "{{
      is_state('binary_sensor.lumi_lumi_motion_ac02_iaszone_3', 'on') }}"
      timeout: "00:00:05"
action:
  - type: turn_on
    device_id: 03974c1a85d3a76c7b10b873ee8e5619
    entity_id: switch.drift_socket_1
    domain: switch
mode: single

Yeah that is not how you use a template condition. Try this:

alias: Entryway - Drfit - Turn on when someone comes in
description: ""
trigger:
  - platform: state
    entity_id: binary_sensor.front_doorbell_motion
    from: 'off'
    to: 'on'
action:
  - wait_for_trigger:
      - platform: state
        entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone_3
        from: 'off'
        to: "on"
    timeout: "00:00:05"
    continue_on_timeout: false
  - service: switch.turn_on
    target:
      entity_id: switch.drift_socket_1
mode: restart

Does the order in which they happen matter?

That worked prefectly. Thanks Tom!

1 Like

Yes. Basically want a light feature to come in only if someone comes in the front door, not if someone is going out.