Hello. Need help properly formatting / formulating a wait_template. The following gives me an error:
- wait_template: "{{ is_state({{ states('input_text.tts_entity_id) }}','idle') }}"
{{ states('input_text.tts_entity_id) }}
translates to media_player.bedrooom_speaker
How to fix?
Thank you.
tom_l
May 18, 2019, 2:07am
2
You missed a single quote after input_text.tts_entity_id
.
Should be:
- wait_template: "{{ is_state({{ states('input_text.tts_entity_id') }}','idle') }}"
But I still dont think this will work.
In the template editor this:
{% set media_id = 'media_player.entranceway_speaker' %}
{{ states('media_player.entranceway_speaker') }}
{{ states('{{ media_id }}') }}
Returns:
off
unknown
.
Thanks for the reply.
I’ve added the missing single quote but still gets the same error:
Invalid config for [script]: [wait_template] is an invalid option for [script]. Check: script->script->script_tts_aws_say->sequence->3->wait_template. (See /config/configuration.yaml, line 34). Please check the docs at Scripts - Home Assistant
if i replace ({{ states('input_text.tts_entity_id') }}
and hard code 'media_player.bedroom_speaker'
it parses fine.
EDIT: Sorry, took a bit of time to realize what you ere pointing out (noob here). Yes, looks like it might not work Thanks in any case.
tom_l
May 18, 2019, 2:25am
4
Yes as I said, I don’t think you can do that.
1 Like
How can I use a workaround similar to this? What’s the correct format / syntax (this is inside a script)
{% if states('input_text.tts_entity_id') == 'meida_player.bedroom_speaker' %}
wait_template: "{{ is_state('meida_player.bedroom_speaker','idle') }}"
(% else %})
wait_template: "{{ is_state('meida_player.kitchen_speaker','idle') }}"
{% endif %}
Thanks again.
tom_l
May 18, 2019, 2:49am
6
This might work:
wait_template: >
{% if states('input_text.tts_entity_id') == 'meida_player.bedroom_speaker' %}
{{ is_state('meida_player.bedroom_speaker','idle') }}
(% else %})
{{ is_state('meida_player.kitchen_speaker','idle') }}
{% endif %}
Thanks. Unfortunately, it also doesn’t seem to work (gives back same error).
For now I’ll probably use something like this (yuck):
- condition: template
value_template: >
{% if states('input_text.tts_entity_id') == 'media_player.downstairs_speaker' %} true {% else %} false {% endif %}
- wait_template: "{{ is_state('media_player.downstairs_speaker','idle') }}"
- condition: template
value_template: >
{% if states('input_text.tts_entity_id') == 'media_player.middle_room_speaker' %} true {% else %} false {% endif %}
- wait_template: "{{ is_state('media_player.middle_room_speaker','idle') }}"
- condition: template
value_template: >
{% if states('input_text.tts_entity_id') == 'media_player.bedroom_speaker' %} true {% else %} false {% endif %}
- wait_template: "{{ is_state('media_player.bedroom_speaker','idle') }}"
- condition: template
value_template: >
{% if states('input_text.tts_entity_id') == 'media_player.elise_s_speaker' %} true {% else %} false {% endif %}
- wait_template: "{{ is_state('media_player.elise_s_speaker','idle') }}"
I think what you’re looking for is:
- wait_template: "{{ is_state(states('input_text.tts_entity_id'), 'idle') }}"
Thanks, but probably won’t work because states('input_text.tts_entity_id')
returns the name of the media player, not the maedia player’s state.
HOMECB
May 18, 2019, 4:15am
11
pnbruckner:
I think what you’re looking for is:
- wait_template: "{{ is_state(states('input_text.tts_entity_id'), 'idle') }}"
Ok, looks like this might actually work. Will test and report back. Thanks everyone for helping a noob out!
Update: Confirmed working. Thank you!
1 Like