Wait for condition to become true?

I have some custom greeting automations, but sometimes, my device is not yet registered as home before I open my front door. I’m wondering if there’s a “wait till the condition is true” configuration that might help with this? I just got a door sensor that I thought might make this a bit more efficient than just wifi home presence. This is an example of what I currently have.

- id: '1577056125739'
  alias: Say Hi 
  description: ''
  trigger:
  - entity_id: binary_sensor.front_door
    platform: state
    to: 'on'
  condition:
  - condition: template
    value_template: '{{ (as_timestamp(states.sensor.time.last_changed) - as_timestamp(states.person.me.last_changed)) < 300 }}'
  - condition: state
    entity_id: person.me
    state: home
  action:
  - data_template:
      message: '{{ (''Hi There!'', ''Welcome Home'', ''Hows it going?'', ''Whats up buttercup?'', ''Howdy pardner'' )|random }}'
    entity_id: media_player.google_home
    service: tts.google_say

Yes, but you have to use it in actions and not conditions.
Take a look at this wait template:

2 Likes

Thanks, I got it working with this.

- id: '1577056125739'
  alias: Say Hi 
  description: ''
  trigger:
  - entity_id: binary_sensor.front_door
    platform: state
    to: 'on'
  action:
  - wait_template: '{{ (as_timestamp(states.sensor.time.last_changed) - as_timestamp(states.person.me.last_changed)) < 300 }}'
    continue_on_timeout: 'false'
    timeout: 00:05:00
  - wait_template: '{{ is_state(''person.me'', ''home'') }}'
    continue_on_timeout: 'false'
    timeout: 00:05:00
  - data_template:
      message: '{{ (''Hi There!'', ''Welcome Home'', ''Hows it going?'', ''Whats up buttercup?'', ''Howdy pardner'' )|random }}'
    entity_id: media_player.google_home
    service: tts.google_say
2 Likes