From 4e7f5c182e970b23a77a5b4d5e77ceeca034b362 Mon Sep 17 00:00:00 2001
From: CCOSTAN <CCOSTAN@users.noreply.github.com>
Date: Fri, 21 Jun 2024 21:56:01 +0000
Subject: [PATCH] #1368 - More voice enhancements and prompt adjustments

---
 config/automation/Speech/announcements.yaml | 16 ++-------
 config/automation/dark_rainy_day.yaml       |  6 ++--
 config/packages/garadget.yaml               |  2 +-
 config/templates/speech/briefing.yaml       | 38 +++++++++++++++++----
 4 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/config/automation/Speech/announcements.yaml b/config/automation/Speech/announcements.yaml
index 8b6517eb..cb73e86f 100755
--- a/config/automation/Speech/announcements.yaml
+++ b/config/automation/Speech/announcements.yaml
@@ -38,21 +38,11 @@
       data:
         personarriving: >
           {% set person = expand('group.arriving')|map(attribute='name')|join(' and ') %}
-          {% set peoplecount = expand('group.arriving') | count %}
-          {% if peoplecount == 1 %}
-            {% set is_are = ' is ' %}
-          {% else %}
-            {% set is_are = ' are ' %}
-          {% endif %}
-          {%- macro greeting_sentence(person, is_are) -%}
-          {{ [
-          "Welcome back home " ~ person,
-          person  ~ is_are + " home now."
-          ] | random }}
-          [Welcome them home in a random style]
+          {%- macro greeting_sentence(person) -%}
+            {{ ["[Welcome " ~ person + " home]"] }}
           {%- endmacro -%}
 
-          {{greeting_sentence(person, is_are)}}
+          {{greeting_sentence(person)}}
         call_responsibilities: 1
         call_no_announcement: 1
         call_garage_check: 1
diff --git a/config/automation/dark_rainy_day.yaml b/config/automation/dark_rainy_day.yaml
index cd9eb238..3ab93019 100755
--- a/config/automation/dark_rainy_day.yaml
+++ b/config/automation/dark_rainy_day.yaml
@@ -12,7 +12,7 @@
       to: 'rain'
     - platform: numeric_state
       entity_id: sensor.pirateweather_precip_intensity
-      above: 0.2
+      above: 0.5
     - platform: numeric_state
       entity_id: sensor.blitzortung_lightning_counter
       above: 1
@@ -30,9 +30,6 @@
     conditions:
       - condition: or
         conditions:
-          # - condition: numeric_state
-          #   entity_id: sensor.pirateweather_cloud_coverage
-          #   above: 90
           - condition: numeric_state
             entity_id: sensor.pirateweather_precip_intensity
             above: 0.2
@@ -64,6 +61,7 @@
     - service: script.speech_engine
       data:
         value1: "Because of the {{trigger.entity_id.split('_')[2]|replace('precip','rain')|replace('counter','lightning')|replace('carlo','rain') }} {{trigger.entity_id.split('_')[3]|replace('intensity',' ')| replace('carlo','and clouds')}} outside.  I will turn on some extra lights in the living room."
+        call_outside_weather: 1
         call_window_check: 1
         call_garage_check: 1
 
diff --git a/config/packages/garadget.yaml b/config/packages/garadget.yaml
index 26ce196f..cee80dfe 100755
--- a/config/packages/garadget.yaml
+++ b/config/packages/garadget.yaml
@@ -320,5 +320,5 @@ automation:
 
       - service: script.speech_engine
         data:
-          value1: "Please check the garage doors. The Small garage is {{ states('cover.small_garage_door')}} and the large garage is {{ states('cover.large_garage_door')}} [Only mention the garage door that is open]"
+          value1: "Check the garage doors. The Small garage is {{ states('cover.small_garage_door')}} and the large garage is {{ states('cover.large_garage_door')}} [Only mention the garage door that is open]"
 
diff --git a/config/templates/speech/briefing.yaml b/config/templates/speech/briefing.yaml
index 0df8c929..ead9ae3c 100755
--- a/config/templates/speech/briefing.yaml
+++ b/config/templates/speech/briefing.yaml
@@ -17,23 +17,49 @@
     {% else %}
     Today is Paige's day to do the chores.
     {% endif %}
-    [Only mention chores if today is garbage day or if this is the only information point you have]
+    [Only mention chores if today is garbage day or if this is the only information you have]
   {%- endmacro -%}
 
   {%- macro inside_weather() -%}
-  Inside the house, it is {{ states.climate.downstairs.attributes['current_temperature'] }} degrees with {{ states('sensor.downstairs_thermostat_humidity') }} percent humidity. [Only mention humidity if it seems unusually high]
+     Inside the house, it is {{ states.climate.downstairs.attributes['current_temperature'] }} degrees with {{ states('sensor.downstairs_thermostat_humidity') }} percent humidity. [Only mention humidity if it seems unusually high]
   {%- endmacro -%}
 
-  {%- macro outside_weather() -%}
+  {%- macro outside_weather2() -%}
   Outside, it is going to be {{ states('sensor.pirateweather_temperature') }} degrees and {{ states('sensor.pirateweather_summary') }} with {{ states('sensor.pirateweather_humidity') }} % humidity. [Only mention humidity if it seems unusually high]
   {%- endmacro -%}
 
+  {% macro outside_weather() %}
+    [Here is the current weather outside]
+    {%- for entity in states.sensor if 'pirateweather' in entity.entity_id %}
+        {%- set state = entity.state %}
+        {%- set unit = entity.attributes.unit_of_measurement if 'unit_of_measurement' in entity.attributes else '' %}
+        {%- set friendly_name = ' '.join(entity.attributes.friendly_name.split(' ')[1:]) %}
+        {%- if state not in ['0', '0.0', 'none'] and 'UV Index' not in friendly_name %}
+        {%- if 'Temperature' in friendly_name -%}
+            {{ friendly_name }}: {{ state }} {{ unit }}
+        {%- elif 'Minutely' in friendly_name -%}
+            {{ friendly_name }}: {{ state }} {{ unit }}
+        {%- elif 'Precip' in friendly_name -%}
+            {{ friendly_name }}: {{ state }} {{ unit }}
+        {%- elif 'Wind Speed' in friendly_name and state | float > 15 -%}
+            {{ friendly_name }}: {{ state }} {{ unit }}
+        {%- elif 'Cloud Coverage' in friendly_name and state | float > 75 -%}
+            {{ friendly_name }}: {{ state }} {{ unit }}
+        {%- elif 'Humidity' in friendly_name and (state | float < 50 or state | float > 85) -%}
+            {{ friendly_name }}: {{ state }} {{ unit }}
+        {%- elif 'Nearest Storm Distance' in friendly_name and state | float <= 10 -%}
+            {{ friendly_name }}: {{ state }} {{ unit }}
+        {%- endif -%}
+        {%- endif %}
+    {% endfor -%}
+  {%- endmacro -%}
+
   {%- macro lightning() -%}
-  There have been {{ states('sensor.blitzortung_lightning_counter') }} lightning strikes detected within {{(states('sensor.blitzortung_lightning_distance') | int(9999)/ 1.69) | round (1, 'floor')}} Miles of our House.  Please make sure everyone is inside the house.
+     There have been {{ states('sensor.blitzortung_lightning_counter') }} lightning strikes detected within {{(states('sensor.blitzortung_lightning_distance') | int(9999)/ 1.69) | round (1, 'floor')}} Miles of our House.  Please make sure everyone is inside the house.
   {%- endmacro -%}
 
   {%- macro fridge() -%}
-  The internal temperature of the refrigerator is currently {{ states('sensor.blink_blink1_temperature') }} degrees.
+    The internal temperature of the refrigerator is currently {{ states('sensor.blink_blink1_temperature') }} degrees.
   {%- endmacro -%}
 
   {%- macro light_check() -%}
@@ -175,7 +201,7 @@
   {% endmacro %}
 
   {%- macro traffic_time() -%} 
-         Current traffic to Spectrum Offices: {{ states.sensor.waze_travel_time.state }} minutes.   
+         Travel Time to Spectrum: {{ states.sensor.waze_travel_time.state }} minutes.   
   {%- endmacro -%}
 
   {# a macro that removes all newline characters, empty spaces, and returns formatted text and replaces underscores with spaces  #}