Is wait_template broken?


#1

I have been trying to use a couple of wait_templates and it seems that if you add anything except the actual template it doesn’t work. Bizarrely (and repeatably) in my experience that includes comments.

Neither of these following examples work, they both wait for the timeout,

- wait_template: >
    {% if is_state('input_boolean.testing_mode', 'on') %}
      {{ is_state('media_player.' ~ states('input_select.notification_test_room'), 'playing') }}
    {% else %}
      {{ is_state('media_player.' ~ room, 'playing') }}
    {% endif %}
  timeout: '00:00:30'

- wait_template: >
  #  {% if is_state('input_boolean.testing_mode', 'on') %}
  #    {{ is_state('media_player.' ~ states('input_select.notification_test_room'), 'playing') }}
  #  {% else %}
    {{ is_state('media_player.' ~ room, 'playing') }}
  #  {% endif %}
  timeout: '00:00:30'

This one does work.

- wait_template: >
    {{ is_state('media_player.' ~ room, 'playing') }}
  timeout: '00:00:30'

My conclusion is that wait_template is broken. Unless you can tell me differently?


#2

You can’t use comment characters like that in multi-line YAML. However, I would think the first template should work just like the last one, assuming input_boolean.testing_mode is off. Does it?


#3

Ok, I didn’t realise that about comments in multi-line YAML. I feel sure I’ve done that before but I must be mistaken. At least that explains that.

input_boolean.testing_mode is off.

And, I too thought the first example should work and I have been scratching my head over this on and off for weeks because couldn’t work out why it would never progress without waiting for the timeout.

So the simple answer is that no, the first example didn’t work for me.

I have now simplified all the wait_templates to the last example and so far in testing it has worked every time. I’ll see how it goes over the next few days in ‘real-life’.

The testing option was very useful though…


#4

If anybody is following this please see my post here