Rewrite speech engine to fix use of variables

This commit is contained in:
2022-09-18 18:46:35 -04:00
parent 254a299b0a
commit 0ed79c494c

View File

@ -511,44 +511,55 @@ script:
{% if voice == 'nabu' %}
script.nabu_voice
{% elif who in ['living_room_echo_dot', 'media_player.living_room_echo_dot','living_room','Living Room Echo Dot','Living Room'] %}
{% set who = 'living_room' %}
script.alexa_voice
{% elif who in ['kallen_bedroom','media_player.kallen_bedroom_speaker','Kallen Bedroom'] %}
{% set who = 'kallen_bedroom' %}
script.jarvis_voice
{% elif who in ['master_bedroom','master_bedroom_echo_dot','media_player.master_bedroom_echo_dot','Master Bedroom Echo Dot','Master Bedroom'] %}
{% set who = 'master_bedroom' %}
script.alexa_voice
{% elif who in ['Basement','basement','basement_echo_dot','media_player.basement_echo_dot','Basement Echo Dot'] %}
{% if is_state('input_boolean.stream_online','on') %}
{% set who = 'living_room' %}
{% set message = 'I cannot play notifications in the basement while the stream is live' %}
{% else %}
{% set who = 'basement' %}
{% endif %}
script.alexa_voice
{% elif who in ['Common Areas','common','common_areas'] %}
{% if is_state('input_boolean.stream_online','on') %}
{% set who = 'living_room' %}
{% else %}
{% set who = 'common' %}
{% endif %}
script.alexa_voice
{% elif who in ['Everywhere','everywhere'] %}
{% if is_state('input_boolean.stream_online','on') %}
{% set who = 'alexa_no_basement' %}
{% else %}
{% set who = 'everywhere' %}
{% endif %}
script.alexa_voice
{% else %}
{% set who = 'living_room_echo_dot' %}
script.alexa_voice
{% endif %}
data:
who: '{{ who }}'
who: >
{% if who in ['living_room_echo_dot', 'media_player.living_room_echo_dot','living_room','Living Room Echo Dot','Living Room'] %}
'living_room'
{% elif who in ['kallen_bedroom','media_player.kallen_bedroom_speaker','Kallen Bedroom'] %}
'kallen_bedroom'
{% elif who in ['master_bedroom','master_bedroom_echo_dot','media_player.master_bedroom_echo_dot','Master Bedroom Echo Dot','Master Bedroom'] %}
'master_bedroom'
{% elif who in ['Basement','basement','basement_echo_dot','media_player.basement_echo_dot','Basement Echo Dot'] %}
{% if is_state('input_boolean.stream_online','on') %}
'living_room'
{% else %}
'basement'
{% endif %}
{% elif who in ['Common Areas','common','common_areas'] %}
{% if is_state('input_boolean.stream_online','on') %}
'living_room'
{% else %}
'common'
{% endif %}
{% elif who in ['Everywhere','everywhere'] %}
{% if is_state('input_boolean.stream_online','on') %}
'alexa_no_basement'
{% else %}
'everywhere'
{% endif %}
{% else %}
'living_room_echo_dot'
{% endif %}
message: >
{{ message }}
{% if who in ['Basement','basement','basement_echo_dot','media_player.basement_echo_dot','Basement Echo Dot'] and is_state('input_boolean.stream_online','on') %}
'I cannot play notifications in the basement while the stream is live'
{% else %}
{{ message }}
{% endif %}
voice: '{{ voice }}'
- condition: template
value_template: >