From 911d96246bc2079f00b88efffa14b6116e58102c Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 29 Aug 2022 18:30:01 -0400 Subject: [PATCH 1/9] New script for announcement --- packages/announcements.yaml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/announcements.yaml b/packages/announcements.yaml index d1fb613..8453251 100644 --- a/packages/announcements.yaml +++ b/packages/announcements.yaml @@ -228,4 +228,17 @@ script: - service: script.status_annc data_template: who: 'everywhere' - call_dinner_is_ready: 1 \ No newline at end of file + call_dinner_is_ready: 1 + + welcome_home: + sequence: + - wait_template: "{{ is_state('binary_sensor.front_door','on') }}" + timeout: + minutes: 5 + continue_on_timeout: false + - delay: + seconds: 5 + - service: script.speech_engine + data_template: + who: living_room + message: !include ../templates/speech/welcome_home.yaml \ No newline at end of file From fac7d30c84cede23adbbe010b6c0f96e0afa111e Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 29 Aug 2022 18:30:27 -0400 Subject: [PATCH 2/9] Call new script from existing script.family_is_home --- packages/presence.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/presence.yaml b/packages/presence.yaml index 0fcac55..b5976a2 100644 --- a/packages/presence.yaml +++ b/packages/presence.yaml @@ -276,6 +276,7 @@ script: entity_id: switch.presence_simulation data: {} - service: script.security_disarm + - service: script.welcome_home - service: switch.turn_off target: entity_id: From 68545546d400f9cc2f61ba9014f23ac4584bd030 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 29 Aug 2022 18:30:47 -0400 Subject: [PATCH 3/9] Placeholder for the announcement content --- templates/speech/welcome_home.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 templates/speech/welcome_home.yaml diff --git a/templates/speech/welcome_home.yaml b/templates/speech/welcome_home.yaml new file mode 100644 index 0000000..a997c50 --- /dev/null +++ b/templates/speech/welcome_home.yaml @@ -0,0 +1,21 @@ +> + {# Script Name Here #} + {%- macro getReport() -%} +

+ Oh dear, I seem to have forgotten how to welcome you home! +

+ {%- endmacro -%} + + {# a macro that removes all newline characters, empty spaces, and returns formatted text #} + {%- macro cleanup(data) -%} + {%- for item in data.split("\n") if item | trim != "" -%} + {{ item | trim }} {% endfor -%} + {%- endmacro -%} + + {# a macro to call all macros :) #} + {%- macro mother_of_all_macros() -%} + {{ getReport() }} + {%- endmacro -%} + + {# Call the macro #} + {{- cleanup(mother_of_all_macros()) -}} \ No newline at end of file From 2786932692495e041364f9ce598764b05cf691ac Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 29 Aug 2022 19:06:37 -0400 Subject: [PATCH 4/9] Basic greeting in place --- templates/speech/welcome_home.yaml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/templates/speech/welcome_home.yaml b/templates/speech/welcome_home.yaml index a997c50..5908f9e 100644 --- a/templates/speech/welcome_home.yaml +++ b/templates/speech/welcome_home.yaml @@ -2,7 +2,23 @@ {# Script Name Here #} {%- macro getReport() -%}

- Oh dear, I seem to have forgotten how to welcome you home! + "Welcome home, " + {% if is_state('person.tony_stork','home') and is_state('person.christina_stork','home') %} + "Stork family. " + {% elif is_state('person.tony_stork','home') %} + "Tony. " + {% elif is_state('person.christina_stork','home') %} + "Tina. " + {% else %} + "Whoever you are, Tony must have broken me again. " + {% endif %} + {% if now().strftime('%H')|int < 12 %} + "I hope you're having a great morning!" + {% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %} + "I hope your afternoon has been a good one!" + {% else %} + "and good evening. I hope you had a good day!" + {% endif %}

{%- endmacro -%} From 55e8b9e6d49d53bc08ed9701e53259a6c03d3d37 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 29 Aug 2022 19:26:45 -0400 Subject: [PATCH 5/9] Weather and climate information --- templates/speech/welcome_home.yaml | 61 +++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/templates/speech/welcome_home.yaml b/templates/speech/welcome_home.yaml index 5908f9e..5013326 100644 --- a/templates/speech/welcome_home.yaml +++ b/templates/speech/welcome_home.yaml @@ -1,5 +1,5 @@ > - {# Script Name Here #} + {# Welcome Home #} {%- macro getReport() -%}

"Welcome home, " @@ -20,6 +20,65 @@ "and good evening. I hope you had a good day!" {% endif %}

+ +

+ As you are no doubt aware, the weather outside is {{ state_attr('weather.iron_nerd_weather_station','temperature') | round }} degrees + {% if is_state('weather.iron_nerd_weather_station','rainy') %} + {{ [ + 'with rain.', + 'with showers.' + ] | random }} + {% elif is_state('weather.iron_nerd_weather_station','cloudy') %} + {{ [ + 'with clouds.', + 'with cloudy skies.' + ] | random }} + {% elif is_state('weather.iron_nerd_weather_station','partlycloudy') %} + {{ [ + 'with some clouds.', + 'with partly cloudy skies.', + 'with scattered clouds.' + ] | random }} + {% elif is_state('weather.iron_nerd_weather_station','sunny') %} + {% if is_state('sun.sun','above_horizon') %} + {{ [ + 'and sunny.', + 'with sun.' + ] | random }} + {% else %} + {{ [ + 'and clear.', + 'with clear skies.' + ] | random }} + {% endif %} + {% else %} + and {{ states.weather.iron_nerd_weather_station.state }} + {% endif %} +

+ +

+ "However, inside the house " + {% if is_state('input_boolean.master_bedroom_aircon_installed','on') %} + "the master bedroom temperature is currently {{ state_attr('climate.master_bedroom_aircon','current_temperature') }} degrees. " + {% if is_state('climate.master_bedroom_aircon','cool') %} + "and the master bedroom air conditioner is currently set for cooling to {{ state_attr('climate.master_bedroom_aircon','temperature') }}. " + {% elif is_state('climate.master_bedroom_aircon','fan_only') %} + "and the master bedroom air conditioner is currently in fan only mode. " + {% elif is_state('climate.master_bedroom_aircon','dry') %} + "and the master bedroom air conditioner is currently moonlighting as a dehumidifier. " + {% elif is_state('climate.master_bedroom_aircon','off') %} + "and the master bedroom air conditioner is currently off. " + {% elif is_state('climate.master_bedroom_aircon','auto') %} + "and the master bedroom air conditioner is making its own decisions. Be afraid, be very afraid. " + {% else %} + "and the master bedroom air conditioner is currently not speaking to me. Was it something I said? " + {% endif %} + {% else %} + "There is no air conditioner or temperature sensor currently installed in the master bedroom. " + {% endif %} + "The first floor thermostat refuses to be my friend. I am very sad about this. You should replace him. Her. It. Whatever. " +

+ {%- endmacro -%} {# a macro that removes all newline characters, empty spaces, and returns formatted text #} From 23c3a8bbc7fa084735fcb7f789001b21806c8f35 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 29 Aug 2022 19:35:36 -0400 Subject: [PATCH 6/9] Minor tweak, didn't like the way the first attempt was read by Polly. --- templates/speech/welcome_home.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/speech/welcome_home.yaml b/templates/speech/welcome_home.yaml index 5013326..10a3d9f 100644 --- a/templates/speech/welcome_home.yaml +++ b/templates/speech/welcome_home.yaml @@ -76,9 +76,9 @@ {% else %} "There is no air conditioner or temperature sensor currently installed in the master bedroom. " {% endif %} - "The first floor thermostat refuses to be my friend. I am very sad about this. You should replace him. Her. It. Whatever. " + "The first floor thermostat refuses to be my friend. I am very sad about this. I mean, who the hell is Honeywell anyway? "

- + {%- endmacro -%} {# a macro that removes all newline characters, empty spaces, and returns formatted text #} From f37d26b555a76296a9e49784a59fbc264c9a8ec4 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 29 Aug 2022 19:49:49 -0400 Subject: [PATCH 7/9] Fixed a minor omission --- templates/speech/welcome_home.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/speech/welcome_home.yaml b/templates/speech/welcome_home.yaml index 10a3d9f..868eaad 100644 --- a/templates/speech/welcome_home.yaml +++ b/templates/speech/welcome_home.yaml @@ -61,7 +61,7 @@ {% if is_state('input_boolean.master_bedroom_aircon_installed','on') %} "the master bedroom temperature is currently {{ state_attr('climate.master_bedroom_aircon','current_temperature') }} degrees. " {% if is_state('climate.master_bedroom_aircon','cool') %} - "and the master bedroom air conditioner is currently set for cooling to {{ state_attr('climate.master_bedroom_aircon','temperature') }}. " + "and the master bedroom air conditioner is currently set for cooling to {{ state_attr('climate.master_bedroom_aircon','temperature') }} degrees. " {% elif is_state('climate.master_bedroom_aircon','fan_only') %} "and the master bedroom air conditioner is currently in fan only mode. " {% elif is_state('climate.master_bedroom_aircon','dry') %} From 31d3ddd9218c2e8aa3f9d5c4a728f68c753a6ac0 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 29 Aug 2022 19:50:18 -0400 Subject: [PATCH 8/9] Added input_boolean condition for welcome home briefing to run --- packages/announcements.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/announcements.yaml b/packages/announcements.yaml index 8453251..a2a33a3 100644 --- a/packages/announcements.yaml +++ b/packages/announcements.yaml @@ -232,6 +232,9 @@ script: welcome_home: sequence: + - condition: state + entity_id: input_boolean.welcome_home + state: 'on' - wait_template: "{{ is_state('binary_sensor.front_door','on') }}" timeout: minutes: 5 From e6216ee328946f2b436ae81027d647e415c6d0a9 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 29 Aug 2022 19:50:37 -0400 Subject: [PATCH 9/9] Information on lights, if after dark --- templates/speech/welcome_home.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/speech/welcome_home.yaml b/templates/speech/welcome_home.yaml index 868eaad..27a7641 100644 --- a/templates/speech/welcome_home.yaml +++ b/templates/speech/welcome_home.yaml @@ -79,6 +79,12 @@ "The first floor thermostat refuses to be my friend. I am very sad about this. I mean, who the hell is Honeywell anyway? "

+

+ {% if is_state('light.living_room_lights','on') %} + "Because it is getting dark, I have turned on the lights for you in the living room, dining room, and mud room. This makes for a total of {{ states.sensor.current_lights_on.state }} lights on. " + {% endif %} +

+ {%- endmacro -%} {# a macro that removes all newline characters, empty spaces, and returns formatted text #}