Wait_template with trigger.to.state

Hi All,

Did a search on forum but didn’t find it.

Is it possible to use wait_template with a trigger.to.state?

  trigger:
    - platform: state
      entity_id:
        - device_tracker.peter_iphone_geofency
        - device_tracker.f1877572_37c4_4bcc_ab05_9e4ac87cb269

  action:
    - wait_template: "{{ not is_state(trigger.to_state.state, 'home') }}"
      timeout: "00:00:15"
      continue_on_timeout: true

Tried this but maybe i do it wrong.

Try this:

- wait_template: "{{ not is_state(trigger.entity_id, 'home') }}"

So after one of your trackers changes state the action waits 15 seconds for it to change again, to home this time. Then if it does not change the actions continues anyway.

Which seems kind of pointless.

What are you actually trying to achieve?

Since iOS 15 the apps "Geofency and “Locative” point sometimes the phone outside the “Home” zone.
Within 10 seconds its going back inside.

To prevent automations will start that we are not at home i do this as workaround.
We had 3 times already that we are not at home then we are back home and the evening scene started in middle of night.

We are in bed, motion detected and the lights went on… not funny whaha…

This will do the same thing:

  trigger:
    - platform: state
      entity_id:
        - device_tracker.peter_iphone_geofency
        - device_tracker.f1877572_37c4_4bcc_ab05_9e4ac87cb269
      from: 'home'
      for: 15
  action:

ehmmm, lets try this… Thanks yaml master!

Solved it. Created 2 automations. 1 for leave and 1 for arrive.
The leave will wait for 15 seconds the arrive will trigger directly. Now its working great.

I knew your option, but i was stuck on the wait_template and didn’t think bigger :slight_smile:

You could also use 1 automation containing 2 triggers. Its action simply uses choose to perform the appropriate actions.

also a option :slight_smile: