]> git.giorgioravera.it Git - homeassistant.git/commitdiff
Added lights to speech and fix minor changes
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Sun, 21 Apr 2019 10:00:14 +0000 (12:00 +0200)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Sun, 21 Apr 2019 10:00:14 +0000 (12:00 +0200)
automation/speech.yaml
script/speech_engine.yaml

index 28e487b00c972de9e1daeb46b4cd3ada89d49b9e..829f5187a98202c4ea5763e0a5f8b7625a7740be 100644 (file)
@@ -83,7 +83,7 @@
           "Sento un interferenza nella Forza! " ~ name + " è qui",
           "Menomale che sei qui " ~ name + "! Mi sentivo solo",
           "Menomale che sei qui " ~ name + "! La casa è vuota senza di te!",
-          "Ciao " ~ name + "! Casa è sempre la casa!",
+          "Ciao " ~ name + "! Casa è sempre la casa!"
           ] | random }}
           {%- endmacro -%}
           {{ greeting_sentence(name) }}
     - service: script.speech_engine
       data_template:
         message: >- 
-          {% set ora = now().strftime('%H') %}
-          "Sono le {{ ora }} e tutto va bene."
+          {% set hour = now().strftime('%H') %}
+          "Sono le {{ hour }} e tutto va bene."
index 903b5fba5710f569a9f1afdbdca22c76a2d9b820..6b1328aa18205876bb766d095911ad24a156f0ed 100644 (file)
@@ -36,12 +36,34 @@ speech_engine:
               Buonanotte.\r
             {% endif %}\r
           {%- endmacro -%}\r
+\r
+          {# Time & Date #}\r
+          {%- macro time_and_date() -%}\r
+            {% set hour = now().strftime('%H') %}\r
+            {% set min = now().strftime('%M') %}\r
+            {% set day = now().strftime('%d') %}\r
+            {% set mounth = now().strftime('%B') %}\r
+            {% set year = now().strftime('%Y') %}\r
+            Sono le {{ hour }} e {{ min }} del {{ day }} {{ mounth }} {{ year }}\r
+          {%- endmacro -%}\r
+            \r
+          {# Lights Status #}\r
+          {%- macro status_lights() -%}\r
+            {% for entity_id in states.group.lights.attributes.entity_id  %}\r
+              {% set name = entity_id.split('.')[1]|replace('_', ' ') %}\r
+              {% if is_state(entity_id, 'off') %}\r
+                La {{ name }} è spenta.\r
+              {% else %}\r
+                La {{ name }} è accesa.\r
+              {% endif %}\r
+            {%- endfor %}\r
+          {%- endmacro -%}\r
           \r
           {# Covers Status #}\r
           {%- macro status_covers() -%}\r
             {% for entity_id in states.group.covers.attributes.entity_id  %}\r
               {% set name = entity_id.split('.')[1]|replace('_', ' ') %}\r
-              {% set perc = states(entity_id) %}\r
+              {% set perc = state_attr(entity_id, 'current_position') %}\r
               {% if perc | int < 25 %}\r
                 La {{ name }} è chiusa.\r
               {% else %}\r
@@ -97,6 +119,20 @@ speech_engine:
             La posizione di Laura è {{ laura_position }}.\r
           {%- endmacro -%}\r
 \r
+          {# End Message #}\r
+          {%- macro end_message() -%}\r
+            {% if enable_status is defined %}\r
+              {% if enable_status | int == 1 %}\r
+                {{ [\r
+                "Spero che il report ti abbia soddisfatto!",\r
+                "Il report è concluso.",\r
+                "Alla prossima!",\r
+                "Non ho altro da comunicare."\r
+                ] | random }}\r
+              {% endif %}\r
+            {% endif %}\r
+          {%- endmacro -%}\r
+\r
           {# *********************************************** #}\r
           {# ******************* Message ******************* #}\r
           {# *********************************************** #}\r
@@ -110,18 +146,25 @@ speech_engine:
           \r
           {% if enable_status is defined %}\r
             {% if enable_status | int == 1 %}\r
+            \r
+              {{ time_and_date() }}\r
+\r
+              {{ status_lights() }}\r
 \r
               {{ status_covers() }}\r
 \r
               {{ status_location() }}\r
             \r
               {{ status_car() }}\r
-              \r
+\r
             {% endif %}\r
           {% endif %}\r
 \r
           {# generic message #}\r
           {{ message }}\r
+          \r
+          {# end message #}\r
+          {{ end_message() }}\r
 \r
 ######################################################################\r
 # Script: Speech Status\r