i tried defining a variable {{ speaker_template }} for my wait_template. i don’t get any errors but the script doesn’t seem to follow the template conditions.
the template syntax is correct because if i place it under the wait_template directly instead of using the {{ speaker_template }} the script will work perfectly.
does anyone know why the wait_template when defined like this in my script?
my idea was to make my speaker_template into 2 templates - alexa_device and google_device. then have 2 sequences inside the script so if an alexa device was specified by the automation the sequence for alexa devices will run and if a google or sonos device was called then the script will run the sequence for google_say.
In your example, the value of the variable speaker_template is computed before it is used in wait_template. The value should be computed bywait_template.
Eliminate the speaker_template variable and use its template in wait_template.
You can do what @123 is saying and also keep the template to a minimum by adjusting the variables output to return the input_boolean instead. And you can use yaml to handle the hard configuration for you.
@petro wow this looks very nice. I’m definitely stealing this code!
i think i want to try modifying it so that i have 2 config variables - one for config_alexa_devices and one for config_google_devices so that i can let the script handle the speaker_service part ie. either notify.alexa_media or tts.google_say.
devices in the config_alexa_device will have one condition template and devices in the config_google_devices will have another condition template
hi @petro, i’m getting error Message malformed: invalid template (TemplateAssertionError: No test named 'None'.) for dictionary value @ data['sequence'][0]['value_template']
what does that mean?
other than that I would like to learn from you :-
I noticed that you moved variables to be immediately after alias.
is this better than placing it under sequence? i guess it makes the variables “global” for the script?
whats the difference doing
announcement_msg: '{{ ("1","2","3") | random }}'
and
announcement_msg: >
{{ ("1","2","3") | random }}
?
is it when using > then i don’t need to enclose the template with ''?
for the condition value template you used "" instead of the single ''. when do we use one or the other?
- condition: template
value_template: "{{ boolean is not None }}"
i also noticed (not here, but elsewhere) sometimes there is a - after the > like so:
announcement_msg: >-
{{ ("1","2","3") | random }}
when would i need to use the >-?
i’m making some changes so the script will handle which speaker uses alexa or google tts.
i have modified my script based on your tips and it is almost where i want it.
I still need some help with that, but i think i should start a new topic for that.