Wait for trigger not working

I try to automate my Front door lights. But if I use automation with wait_for_trigger doesn’t work. If i use delay instead wait its working.
My config look like this:

 alias: Swiatla porch
 description: ""
 trigger:
   - platform: state
     entity_id:
       - binary_sensor.porch_swiatlo
     from: "off"
     to: "on"
 condition:
   - condition: sun
     after: sunset
     before: sunrise
 action:
   - service: switch.turn_on
     data: {}
     target:
       entity_id: switch.porch_swiatla_switch
   - wait_for_trigger:
       - platform: state
         entity_id:
           - binary_sensor.front_door_motion
         from: "on"
         to: "off"
         for:
           hours: 0
           minutes: 0
           seconds: 0
     timeout:
       hours: 0
       minutes: 0
       seconds: 0
       milliseconds: 0
     enabled: true
   - service: switch.turn_off
     data: {}
     enabled: true
     target:
       entity_id: switch.porch_swiatla_switch
 mode: single

Its execute all automation without wait trigger.

Can you remove timeout part from automation? (Just guessing)

To me, it looks like it is timing out immediately without waiting for trigger. Moreover traces would be very helpful for debugging.

@anon63427907 is correct, because you have set timeout to 0, the wait is timing out and continuing instantly.

If you want to specify a timeout so the automation doesn’t wait forever, you need to specify a time for the timeout. Additionally, if you don’t want the switch to be turned off if the wait times out, you need to include continue_on_timeout: false in the wait action.

1 Like

@fuatakgun
Thanks fixed as you suggested and its working.
I’m getting too old for that stuff.
@Didgeridrew
Thank you as well for explaining.

1 Like