From 0ed79c494cdeeb8a8b1d31e0c43d7b254af50072 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Sun, 18 Sep 2022 18:46:35 -0400 Subject: [PATCH] Rewrite speech engine to fix use of variables --- packages/notify.yaml | 55 ++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/packages/notify.yaml b/packages/notify.yaml index be73b33..64e6120 100644 --- a/packages/notify.yaml +++ b/packages/notify.yaml @@ -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: >