Hey there! I have some issues after Home Assistant update I think (but not sure)
I started to get an error
Error executing script. Unexpected error for call_service at pos 3: {'request_id': '4051a490-df26-423e-94d6-899909bcef46', 'status': 'error', 'code': 'INVALID_VALUE', 'message': Message can contain only strings and symbols "-,!.:=?".'}
It seems like tts command is not processed correctly
This does not work:
- service: media_player.play_media
entity_id: media_player.yandex_mini
data_template:
media_content_id: >
Добро пожаловать домой, {% set alias = {'Арго':'Арго', 'Армен':'Армен', 'Гаяне':'Гаяне', 'Олеся':'Олеся'} %}
{% set people_home = states.person | selectattr('state','eq','home') | map(attribute='attributes.friendly_name') | list %}
{% set ns = namespace(occupants = '') %}
{% for i in people_home %}
{% set ns.occupants = ns.occupants ~ ' ' ~ alias.get(i,i) if loop.index > 1 else alias.get(i,i) %}
{% endfor %}
{{ ns.occupants }}
But this works:
- service: media_player.play_media
entity_id: media_player.yandex_mini
data_template:
media_content_id: Добро пожаловать домой, {% set alias = {'Арго':'Арго', 'Армен':'Армен', 'Гаяне':'Гаяне', 'Олеся':'Олеся'} %}{% set people_home = states.person | selectattr('state','eq','home') | map(attribute='attributes.friendly_name') | list %}{% set ns = namespace(occupants = '') %}{% for i in people_home %}{% set ns.occupants = ns.occupants ~ ' ' ~ alias.get(i,i) if loop.index > 1 else alias.get(i,i) %}{% endfor %}{{ ns.occupants }}
media_content_type: text
I also tried ‘|’ instead of ‘>’ but that did not work. Seems like my template is not read as one string of text
Yeah, I just corrected it and it works. Also found open issue on the same problem on yandex component. If anyone needs - here is it (be careful, russian language)
Thanks for quick response and help with the template
Good question. Because in the other post, Argo said TTS wasn’t pronouncing the names correctly (and they were presented using the Latin, not Cyrillic alphabet). I suggested he use appropriate phonetic replacements. At the time, the idea was accepted (although never formally marked as a Solution):
One year later, I see the technique was misapplied to the extent of making it unnecessary … resulting in your valid question: Why even have the map?
As I have mentioned - I needed correct pronouncing that days. I just switched my dumb speaker to smart speaker from yandex (like google home mini). It is pronouncing everything correctly
I really appreciate your help, I used that template for 10 months and it worked as it should. Sorry that I did not mark your answer as a solution, it definitely was.
And I still find jinja a little bit messy even after learning python (junior level) and having around 5 months of working in IT department using mainly python. I still struggle to make my own templates longer than 1 sentence (that’s why I did not cut map and optimise the template)