From ac643da3a13f6e9685b76ed08b52f998ea3ae4c4 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Thu, 13 Oct 2022 17:18:44 -0400 Subject: [PATCH] Nightly briefing added #52 --- packages/announcements.yaml | 24 ++++++++ packages/scheduling.yaml | 5 ++ templates/speech/nightly_briefing.yaml | 79 ++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 templates/speech/nightly_briefing.yaml diff --git a/packages/announcements.yaml b/packages/announcements.yaml index 9c88e07..ee6d7d0 100644 --- a/packages/announcements.yaml +++ b/packages/announcements.yaml @@ -147,6 +147,23 @@ automation: data: who: common + - id: 933acebd-c788-4640-babd-6c30093cd2ba + alias: Nightly Briefing + trigger: + platform: time + at: input_datetime.nightly_report + condition: + - condition: state + entity_id: binary_sensor.people_present + state: 'on' + - condition: state + entity_id: input_boolean.vacation_mode + state: 'off' + action: + - service: script.nightly_briefing + data: + who: common + - id: d7641b5e-3cbb-4fb3-b6ed-5edf3157b88d alias: Kallen Briefing Location Change trigger: @@ -236,6 +253,13 @@ script: who: "{{ who }}" message: !include ../templates/speech/daily_briefing.yaml + nightly_briefing: + sequence: + - service: script.speech_engine + data_template: + who: "{{ who }}" + message: !include ../templates/speech/nightly_briefing.yaml + morning_report: sequence: - service: script.speech_engine diff --git a/packages/scheduling.yaml b/packages/scheduling.yaml index 12012c5..d75f503 100644 --- a/packages/scheduling.yaml +++ b/packages/scheduling.yaml @@ -331,6 +331,11 @@ script: house_scheduling_evening: sequence: + - service: input_datetime.set_datetime + entity_id: input_datetime.nightly_report + data: + time: > + {{ (state_attr('input_datetime.kallen_bedtime','timestamp') - 3600) | timestamp_custom('%H:%M', false) }} - service: input_datetime.set_datetime entity_id: input_datetime.audible_notification_off data_template: diff --git a/templates/speech/nightly_briefing.yaml b/templates/speech/nightly_briefing.yaml new file mode 100644 index 0000000..82a49ff --- /dev/null +++ b/templates/speech/nightly_briefing.yaml @@ -0,0 +1,79 @@ +> + {# Nightly Briefing #} + {%- macro getReport() -%} +

+ "Good evening. It is {{ now().strftime("%I:%M %p") }}. As the day reaches its end, here are a few items to wrap things up. " +

+ +

+ {% if is_state('input_boolean.tony_streaming_today','on') %} + "Tony will be streaming tonight. The studio is scheduled to go live at {{ (state_attr('input_datetime.tony_streaming_start_time','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + {% endif %} + {% if is_state('sensor.school_tomorrow','on') %} + {% if is_state('sensor.band_tomorrow','on') %} + "Kallen has school tomorrow, and there will be band practice in the morning. " + {% else %} + "Kallen has school tomorrow. " + {% endif %} + {% endif %} + "I am currently unable to tell you whether Tina works tomorrow. Coming soon, I hope. " +

+ +

+ "Bedroom climate scheduling will be as follows. " + {% if is_state('input_boolean.master_bedroom_aircon_installed','on') %} + {% if is_state('input_select.scheduled_climate_mode_master_bedroom_aircon','AC') %} + "The master bedroom air conditioner will activate cooling mode at {{ (state_attr('input_datetime.master_bedroom_cooling','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + {% elif is_state('input_select.scheduled_climate_mode_master_bedroom_aircon','Fan') %} + "The master bedroom air conditioner will activate fan only mode at {{ (state_attr('input_datetime.master_bedroom_cooling','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + {% elif is_state('input_select.scheduled_climate_mode_master_bedroom_aircon','None') %} + "The master bedroom air conditioner will remain inactive tonight. " + {% endif %} + {% endif %} + {% if is_state('input_select.scheduled_climate_mode_master_bedroom_fan','Fan') %} + "The master bedroom fan will activate at {{ (state_attr('input_datetime.master_bedroom_fan','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + {% elif is_state('input_select.scheduled_climate_mode_master_bedroom_fan','None') %} + "The master bedroom fan will remain inactive tonight. " + {% endif %} + {% if is_state('input_boolean.kallen_overnight','off') %} + {% if is_state('input_select.scheduled_climate_mode_kallen_fan','Fan') %} + "Colin's fan will activate at {{ (state_attr('input_datetime.kallen_bedtime','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + {% elif is_state('input_select.scheduled_climate_mode_kallen_fan','White Noise') %} + "Colin's white noise generator will activate at {{ (state_attr('input_datetime.kallen_bedtime','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + {% elif is_state('input_select.scheduled_climate_mode_kallen_fan','None') %} + "Colin's room will have no devices activated tonight. " + {% endif %} + {% else %} + "Colin's room will be left alone, as he is spending the night elsewhere tonight. " + {% endif %} + {% if is_state('input_boolean.nursery_aircon_installed','on') %} + {% if is_state('input_select.scheduled_climate_mode_nursery_aircon','AC') %} + "Emma's air conditioner will be activated at {{ (state_attr('input_datetime.nursery_cooling','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + {% elif is_state('input_select.scheduled_climate_mode_nursery_aircon','White Noise') %} + "Emma's white noise generator will activate at {{ (state_attr('input_datetime.nursery_cooling','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " + {% elif is_state('input_select.scheduled_climate_mode_nursery_aircon','None') %} + "Emma's room will have no devices activated tonight. " + {% endif %} + {% endif %} +

+ +

+ "This briefing is a work in progress. Stay tuned in the coming days for more updates! " +

+ + + {%- 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