]> git.giorgioravera.it Git - homeassistant.git/commitdiff
Fix problem with voice notifications with text length
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Mon, 14 Dec 2020 09:34:32 +0000 (10:34 +0100)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Mon, 14 Dec 2020 09:34:32 +0000 (10:34 +0100)
packages/alarm/alarm_notifications.yaml
scripts/notify.yaml

index 016c8099ebc569d7e307587b8608c09c51cdd9c5..9c1394edde274345979a4978dc5e79581bc97ed1 100644 (file)
@@ -1,8 +1,8 @@
-######################################################################\r
-# Alarm Package - Notifications Scripts\r
-######################################################################\r
+######################################################################
+# Alarm Package - Notifications Scripts
+######################################################################
 
-script: \r
+script: 
   ######################################################################
   # Alarm: Start Alarm Sound
   #
@@ -45,10 +45,10 @@ script:
   ######################################################################
   # Alarm: Start Alarm
   # Inputs:
-  # - entity_id\r
+  # - entity_id
   # - title
   # - message
-  # - level\r
+  # - level
   #
   # Operations:
   # - input_boolean.turn_on
@@ -58,57 +58,57 @@ script:
   start_alarm:
     alias: "Allarmi: Attiva Allarme"
     sequence:
-      - service: input_boolean.turn_on\r
+      - service: input_boolean.turn_on
         data_template: 
-          entity_id: >\r
-            {# Check Null Input #}\r
-            {% if entity_id | length == 0 %}\r
-              {% set entity_id = 'input_boolean.generic_alarm' %}\r
-            {% endif %}\r
-            {{ entity_id }}\r
-\r
+          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\r
-        data_template:\r
-          volume_level: 0.4\r
-          language: 'it'\r
-          title: >-\r
-            {# Check Null Input #}\r
-            {% if title | length == 0 %}\r
-              {# Check Null Input #}\r
-              {% if entity_id | length == 0 %}\r
-                {% set entity_id = 'input_boolean.generic_alarm' %}\r
-              {% endif %}\r
-              {% set title = state_attr(entity_id, 'friendly_name') %}\r
-            {% endif %}\r
-            Home Assistant - {{ title }}\r
-          message: >-\r
-            {# Check Null Input #}\r
-            {% if message | length == 0 %}\r
-              {# Check Null Input #}\r
-              {% if entity_id | length == 0 %}\r
-                {% set entity_id = 'input_boolean.generic_alarm' %}\r
-              {% endif %}\r
-              {% set message = state_attr(entity_id, 'friendly_name') %}\r
-            {% endif %}\r
-            {{ message }}\r
-          enable_persistent: 1\r
-          notification_id: "alarm"\r
-\r
-      # LEVEL 2\r
-      - condition: template\r
-        value_template: >-\r
-          {# Check Null Input #}\r
-          {% if level | length == 0 %}\r
-            {% set level = 1 %}\r
-          {% endif %}\r
-          {% if level | int >= 2 %}\r
-            true\r
-          {% else %}\r
-            false\r
-          {% endif %}\r
-\r
-      - service: script.start_alarm_sound\r
+      - 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
index 0391b2fc7060b4f7812a2ca8467f7ecf47d47522..cdddd1dfb763a6b78c141c61f28ae34d2cb9ed6e 100644 (file)
@@ -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 %}