From 62534bb9c3755372a13b12c1d37db9d9979510f4 Mon Sep 17 00:00:00 2001 From: Giorgio Ravera Date: Mon, 14 Dec 2020 10:34:32 +0100 Subject: [PATCH] Fix problem with voice notifications with text length --- packages/alarm/alarm_notifications.yaml | 110 ++++++++++++------------ scripts/notify.yaml | 2 +- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/packages/alarm/alarm_notifications.yaml b/packages/alarm/alarm_notifications.yaml index 016c8099..9c1394ed 100644 --- a/packages/alarm/alarm_notifications.yaml +++ b/packages/alarm/alarm_notifications.yaml @@ -1,8 +1,8 @@ -###################################################################### -# Alarm Package - Notifications Scripts -###################################################################### +###################################################################### +# Alarm Package - Notifications Scripts +###################################################################### -script: +script: ###################################################################### # Alarm: Start Alarm Sound # @@ -45,10 +45,10 @@ script: ###################################################################### # Alarm: Start Alarm # Inputs: - # - entity_id + # - entity_id # - title # - message - # - level + # - level # # Operations: # - input_boolean.turn_on @@ -58,57 +58,57 @@ script: start_alarm: alias: "Allarmi: Attiva Allarme" sequence: - - service: input_boolean.turn_on + - service: input_boolean.turn_on data_template: - entity_id: > - {# Check Null Input #} - {% if entity_id | length == 0 %} - {% set entity_id = 'input_boolean.generic_alarm' %} - {% endif %} - {{ entity_id }} - + entity_id: > + {# Check Null Input #} + {% if entity_id | length == 0 %} + {% set entity_id = 'input_boolean.generic_alarm' %} + {% endif %} + {{ entity_id }} + # LEVEL 1 - - service: script.notify_all - data_template: - volume_level: 0.4 - language: 'it' - title: >- - {# Check Null Input #} - {% if title | length == 0 %} - {# Check Null Input #} - {% if entity_id | length == 0 %} - {% set entity_id = 'input_boolean.generic_alarm' %} - {% endif %} - {% set title = state_attr(entity_id, 'friendly_name') %} - {% endif %} - Home Assistant - {{ title }} - message: >- - {# Check Null Input #} - {% if message | length == 0 %} - {# Check Null Input #} - {% if entity_id | length == 0 %} - {% set entity_id = 'input_boolean.generic_alarm' %} - {% endif %} - {% set message = state_attr(entity_id, 'friendly_name') %} - {% endif %} - {{ message }} - enable_persistent: 1 - notification_id: "alarm" - - # LEVEL 2 - - condition: template - value_template: >- - {# Check Null Input #} - {% if level | length == 0 %} - {% set level = 1 %} - {% endif %} - {% if level | int >= 2 %} - true - {% else %} - false - {% endif %} - - - service: script.start_alarm_sound + - service: script.notify_all + data_template: + volume_level: 0.4 + language: 'it' + title: >- + {# Check Null Input #} + {% if title | length == 0 %} + {# Check Null Input #} + {% if entity_id | length == 0 %} + {% set entity_id = 'input_boolean.generic_alarm' %} + {% endif %} + {% set title = state_attr(entity_id, 'friendly_name') %} + {% endif %} + Home Assistant - {{ title }} + message: >- + {# Check Null Input #} + {% if message | length == 0 %} + {# Check Null Input #} + {% if entity_id | length == 0 %} + {% set entity_id = 'input_boolean.generic_alarm' %} + {% endif %} + {% set message = state_attr(entity_id, 'friendly_name') %} + {% endif %} + {{ message }} + enable_persistent: 1 + notification_id: "alarm" + + # LEVEL 2 + - condition: template + value_template: >- + {# Check Null Input #} + {% if level | string | length == 0 %} + {% set level = 1 %} + {% endif %} + {% if level | int >= 2 %} + true + {% else %} + false + {% endif %} + + - service: script.start_alarm_sound ###################################################################### # Alarm: Stop Alarm diff --git a/scripts/notify.yaml b/scripts/notify.yaml index 0391b2fc..cdddd1df 100644 --- a/scripts/notify.yaml +++ b/scripts/notify.yaml @@ -88,7 +88,7 @@ volume_manager: {% set maxNightVolume = 0.20 %} {# Check Null Input #} - {% if volume_level | length == 0 %} + {% if volume_level | string | length == 0 %} {% set volume_level = defaultVolume %} {% endif %} -- 2.47.3