Wait template

Hi All,

Can someone help me out? I think I can’t see the problem anymore. This part of automation is not woking
When automation has been triggered after 10 seconds the script is going on. It won’t wait for the wait part that the front door has been status ‘on’

entity

friendly_name: Fibaro Frontdoor
device_class: door
templates:
  icon_color: >-
    if (state === 'on') return 'rgba(251,214,67,1)'; return
    'rgba(71,116,157,1)';
icon_color: 'rgba(71,116,157,1)'

state

on

automation part

  action:
    - wait_template: >-
        {{ (states("binary_sensor.fibaro_frontdoor_custom_sensor") == 'on') }}
    - delay: "00:00:10"

full automation:

###########################################################################################
# NOTIFY and GREETS PERSON WHO WENT HOME
###########################################################################################

- alias: "Notify - Greets People Home"
  trigger:

    - platform: state
      entity_id:
        - input_boolean.peter_home_manual
        - input_boolean.kay_home_manual
      from: "off"
      to: "on"

  action:
    - wait_template: >-
        {{ (states("binary_sensor.fibaro_frontdoor_custom_sensor") == 'true') }}

    - delay: "00:00:10"

      ###########################################################################################
      # GROUP.ARRIVING is created in create_arrive_group.yaml
      ###########################################################################################
    - service: script.engine_say
      data_template:
        personarriving: >-
          {% set person = expand('group.arriving')|map(attribute='name')|join(' and ') %}
          {% set peoplecount = expand('group.arriving') | count %}
          {% if peoplecount == 1 %}
            {% set is_are = ' is ' %}
          {% else %}
            {% set is_are = ' are ' %}
          {% endif %}

          {%- macro greeting_sentence(person, is_are) -%}
          {{ [
            "Welcome back home " ~ person,
            "You had me at hello " ~ person,
            "Guess who is home? " ~ person ~ is_are ,
            "The wifi just got a little more crowded.  Welcome Home " ~ person,
            "Welcome Home " ~ person + ".  We have missed you. Or at least Molly did.",
            "Our home is now complete, Rest your head and relax your feet! Welcome Back " ~ person,
            "Life is like a song, you’re back where you belong. Welcome home " ~ person,
            "Hey there " ~ person + " Welcome Home!",
            "Knock Knock. Who is There? "   ~ person  ~ is_are ,
            "The front door just told me that " ~ person  ~ is_are +" home.",
            "I know a secret! "  ~ person  ~ is_are +" home!",
            "Hey "  ~ person +". Your arrival has been recorded by the Smartest house on the block.",
            "Take note Molly! "  ~ person  ~ is_are +" home.",
            "I am sensing a disturbance in the force. "  ~ person +" must be home!",
            "And the house becomes a home. Welcome back " ~ person,
            "Just a quick announcement. " ~ person +" has arrived!",
            "Hey " ~ person + "! High Five! Glad you are finally home.",
            "Pardon the interruption but " ~ person ~ is_are +" home!",
            "My systems are picking up the presence of additional humans. " ~ person  ~ is_are +" being identified as home.",
            "Welcome home "~person + "! It is nice to see you again! Let me turn on the lights. ",
            "It looks like "~person ~ is_are + " finally home! I will get the house ready for you. ",
            person  ~ is_are + " now in the house.",
            person + " can not hide from the system. Welcome home.",
            person ~ "! You are home!",
            person  ~ is_are + " now here.  Hash tag Welcome Home.",
            person  ~ is_are + " now here.  Hash tag Home.",
            person  ~ is_are + " now here.  Hash tag Smart Home."
          ] | random }}
          {%- endmacro -%}
          {{greeting_sentence(person, is_are)}}

    - service: group.set
      data_template:
        object_id: "arriving"
        entities: []

The wait template is set up to wait until the sensor is on.

You said the sensor was already on:

So it’s going to blast right past the wait template into the 10 second delay.

Sorry for my bad English :slight_smile:

No the on status was to show that the state give ‘on’ back when I check the sensor in developer tool

When I use the developer template with the state line and open or close the door I get “true” and “false” when I test the state line. But in the automation it get skipped.

Currently if an automation triggers more than once while waiting in a delay or wait template it will cancel wait templates/delay and move to the next step in the sequence. This has been fixed in 0.113.

Ok thanks. Have to wait for 0.113 release then :slight_smile:

You could try the beta release.

Untitled

1 Like

Not sure when 0.113.0 is arriving but the new default action for automations will fix this issue as Tom points out.
If you don’t fancy joining the beta channel, you could just insert a condition so that it won’t run if an input boolean is on, then have the first action set the boolean to on, do what you need to do and reset the boolean at the end.
It should get you out of a pickle and won’t cause a problem in the sooner to be released upgrade (just in case you forget to remove it), though it is an extra input_boolean kicking around in the yard.

1 Like

I love to see new things but I stay at the stable version. Otherwise my BF is killing me when things goes wrong haha :wink:

First you showed this under “automation part”:

But then you showed this under “full automation”:

The first one is ok, but the second one would never complete. So which did you actually use in your automation?

By the way, you should probably use the is_state() function, like this:

    - wait_template: >-
        {{ is_state('binary_sensor.fibaro_frontdoor_custom_sensor', 'on') }}

But what others have said is true, a second trigger would cause either the wait_template or delay step to be canceled and the automation would continue to the next step. This is fixed in 0.113.

1 Like

Use the first one. The second one I tried but forget to change it here

1 Like

Your use of idiom is excellent and I would say “of a native English speaker” but your “other” sentence construction is just a “bit off”. Still, I wish I spoke your native language about half as well as you do English. What is your native tongue ?

BTW it’s Phil to whom we owe the debt of thanks for the major improvements coming in 0.113.0

:+1: Well caught @pnbruckner, it just shows we read what we expect to see, not what is actually there (and with code, that’s a big difference ! )

Thanks. Native tongue is Dutch (Nederlands) the country of Drop, Windmills and wooden shoes haha.

I will wait for the update, at some point it will be released!

Read the changelog for 0.113.x … Automation/Script improvement seems very nice!!! Its now sitting in my head to update my stable to beta. Can you tell me how buggy HA beta’s can be? :slight_smile:

This one seems quite stable according to the talk in the discord beta channel (which you should join for latest news and to report issues) . https://discord.gg/HGwZc7

Precautions are always wise though. Make sure you have a current backup stored off your server before joining the beta program.

Always. I will think about it. my stable HA is running perfect with no issues at all except this wait part, but thats only for fancy greetings …

Hi, fellow cheese eater :wink:

Can you explain to me in which part of the yaml file I have to place the wait template?
I have a TSS message that’s not audible. I think, due to the fact it goes into idle right away. Maybe this template is the solution for my problem.

Thanks in advcance! (alvast dank voor je hulp!)

Hey Dutchie, Here the whole config how its done and working perfect here:

The 2 input_booleans are added so they are visible in Homekit.
In Homekit i have 4 automations, 2 when leaving the area and 2 when arriving the area.
The last 2 are important. Because this will trigger the automation below.

The wait_template is because when you open the front door it will proceed the automation. The there is a delay (you can remove that one if you want) it wait 1 minute before it will announce on Alexa.

The part of group.set is because it will store just 1 or 2 persons into the group. The announcement will be then “Welcome back home Peter” or “Welcome back home Kay” or “Welcome back home Peter and Kay”

###########################################################################################
# NOTIFY and GREETS PERSON WHO WENT HOME
###########################################################################################
- id: "2db1a9ac-a77d-446c-ab69-240d5c31c34e"
  alias: "Notification - Greets people home"
  mode: restart
  trigger:
    - platform: state
      entity_id:
        - input_boolean.helpers_peter_home_homekit
        - input_boolean.helpers_kay_home_homekit
      from: "off"
      to: "on"

  condition: []

  action:
    - service: group.set
      data:
        object_id: "arriving"
        add_entities: "{{ trigger.to_state.entity_id }}"

    - wait_template: "{{ is_state('binary_sensor.frondoor_door_contact', 'on') }}"

    - delay: "00:01:00"

      ###########################################################################################
      # GROUP.ARRIVING is created in create_arrive_group.yaml
      ###########################################################################################
    - continue_on_error: true
      service: "{{ 'script.none' if is_state('input_select.helpers_scenes', 'scene goodnight') else 'script.engine_say' }}"
      data:
        media_player: media_player.livingroom
        notify: notify.alexa_media_livingroom
        personarriving: >-
          {% set person = expand('group.arriving')|map(attribute='name')|join(' and ') %}
          {% set peoplecount = expand('group.arriving') | count %}
          {% if peoplecount == 1 %}
            {% set is_are = ' is ' %}
          {% else %}
            {% set is_are = ' are ' %}
          {% endif %}

          {%- macro greeting_sentence(person, is_are) -%}
          {{ [
            "Welcome back home " ~ person,
            "You had me at hello " ~ person,
            "Guess who is home? " ~ person ~ is_are ,
            "The wifi just got a little more crowded.  Welcome Home " ~ person,
            "Welcome Home " ~ person + ".  We have missed you. Or at least Molly did.",
            "Our home is now complete, Rest your head and relax your feet! Welcome Back " ~ person,
            "Life is like a song, you’re back where you belong. Welcome home " ~ person,
            "Hey there " ~ person + " Welcome Home!",
            "Knock Knock. Who is There? "   ~ person  ~ is_are ,
            "The front door just told me that " ~ person  ~ is_are +" home.",
            "I know a secret! "  ~ person  ~ is_are +" home!",
            "Hey "  ~ person +". Your arrival has been recorded by the Smartest house on the block.",
            "Take note Molly! "  ~ person  ~ is_are +" home.",
            "I am sensing a disturbance in the force. "  ~ person +" must be home!",
            "And the house becomes a home. Welcome back " ~ person,
            "Just a quick announcement. " ~ person +" has arrived!",
            "Hey " ~ person + "! High Five! Glad you are finally home.",
            "Pardon the interruption but " ~ person ~ is_are +" home!",
            "My systems are picking up the presence of additional humans. " ~ person  ~ is_are +" being identified as home.",
            "Welcome home "~person + "! It is nice to see you again!",
            "It looks like "~person ~ is_are + " finally home! I will get the house ready for you. ",
            person  ~ is_are + " now in the house.",
            person + " can not hide from the system. Welcome home.",
            person ~ "! You are home!",
            person  ~ is_are + " now here.  Hash tag Welcome Home.",
            person  ~ is_are + " now here.  Hash tag Home.",
            person  ~ is_are + " now here.  Hash tag Smart Home."
          ] | random }}
          {%- endmacro -%}
          {{greeting_sentence(person, is_are)}}

    - service: group.set
      data:
        object_id: "arriving"
        entities: []

Hi all, I am wondering if someone can help. I have created a simple automation that turns on outdoor lights at sunset and sets brightness to 75%. At 23:00 it should dim the lights to 15%. At 23:59:59 it should turn off 2 out of 3 lights. The 3rd light should turn off 2 hours before sunrise.

Here is my code:

alias: Exterior - Evening Lights Automation
description: ""
trigger:
  - platform: sun
    event: sunset
condition: []
action:
  - service: light.turn_on
    data:
      brightness_pct: 75
    target:
      entity_id:
        - light.front_facade
        - light.outside_entrance
        - light.outside_columns
  - wait_for_trigger:
      - platform: time
        at: "23:00:00"
    timeout:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: light.turn_on
    data:
      brightness_pct: 15
    target:
      entity_id:
        - light.front_facade
        - light.outside_columns
        - light.outside_entrance
  - wait_for_trigger:
      - platform: time
        at: "23:59:59"
    timeout:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: light.turn_off
    data: {}
    target:
      entity_id:
        - light.front_facade
        - light.outside_columns
  - wait_for_trigger:
      - platform: sun
        event: sunrise
        offset: "-02:00:00"
    timeout:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.outside_entrance
mode: single

The problem I have is that the automation triggers at sunset and the lights come on, but then it becomes unavailable according to the logs and the lights remain on.

Can anyone explain what I have done wrong?

I don’t know if a wait template can wait after 00:00:00 day change. Maybe you can create a new automation just for the offset sunrise?

1 Like

I see, so going over the 23:59:59 can stop it! Ok will try that.