Wait for trigger not working in welcome home automation

I dont understand what’s going wrong here. I want my house to give me an update on some things as soon as me (or my husband in this case) come home and open the door in the next 2 minutes. If the door is not opened in 2 minutes I do not want it to continue.

For a long time I accomplished this by using the door opening as the trigger and I had a condition that was a 2 minute timer - started the moment we got home. That worked fine but it took 3 different automations to accomplish and just didnt feel like a concise solution. I’ve used wait for trigger numerous times since in other automations and it works perfectly so I decided to try to use it to clean this one up.

When I manually change his location to something else and then back to home, it triggers the automation but nothing happens when I open the door. Am I using timeout wrong? It seems to me like continue on timeout would mean continue running actions after 2 minutes even if the trigger never comes. I do not want it to do that, I want the automation to stop. Even though I can see that the door state is going from off to on within the 2 minute window, it aborts every time.

alias: welcome me home - Matt
description: welcome person home when the door is opened and give an update on the house
trigger:
  - platform: state
    entity_id:
      - person.matt
    to: home
condition: []
action:
  - wait_for_trigger:
      - platform: state
        entity_id:
          - binary_sensor.front_door_iaszone_2
        to: "on"
        from: "off"
    timeout:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
    continue_on_timeout: false
  - service: notify.alexa_media_echo_show_8_2nd_gen
    data:
      data:
        type: tts
      message: >-
        Welcome home. The thermostat is set to
        {{states('climate.tstat_5df596_t5_thermostat')}} to    
        {{state_attr('climate.tstat_5df596_t5_thermostat', 'temperature')}} and
        the vacuum last ran {{ relative_time(states.vacuum.dustin.last_changed)
        }} ago
mode: single

Manually changing the area status of entities for testing automations have proven unreliable to me and the reason for countless, baffling behaviors. To the point where today I simple wait for the entity to actually move in/out of the area in order to test.

This all looks correct and should do what you want:

The only reason I can think of that would cause it not to trigger and to time out (as per your automation trace) is if the entity id is not correct. Double check that first. Then check its state history.

You were absolutely correct. I feel like a dummy. The door sensor had to be re-added to the zigbee network after being offline for a long time and I didnt realize it had reverted to a different entity id. Changing the entity id fixed it. Thanks for reminding me to check that!

1 Like