diff --git a/packages/announcements.yaml b/packages/announcements.yaml index f238d5b..be19bd8 100644 --- a/packages/announcements.yaml +++ b/packages/announcements.yaml @@ -87,6 +87,18 @@ automation: action: - service: script.kallen_nightly_briefing + - id: c53d84ee-9e6d-4268-8d44-d427c722602a + alias: Daily Briefing + trigger: + platform: time + at: input_datetime.daily_report + condition: + condition: state + entity_id: binary_sensor.people_present + state: 'on' + action: + - service: script.daily_briefing + script: reset_annc_switches: sequence: @@ -134,4 +146,11 @@ script: - service: script.text_notify data: who: "ios_parents" - message: "I just gave Kallen's morning briefing" \ No newline at end of file + message: "I just gave Kallen's morning briefing" + + daily_briefing: + sequence: + - service: script.speech_engine + data: + who: living_room + message: !include ../templates/speech/daily_briefing.yaml \ No newline at end of file diff --git a/templates/speech/daily_briefing.yaml b/templates/speech/daily_briefing.yaml new file mode 100644 index 0000000..bbf6e5b --- /dev/null +++ b/templates/speech/daily_briefing.yaml @@ -0,0 +1,304 @@ +> + {# Daily Briefing #} + {%- macro getReport() -%} +
+ {% if now().strftime('%H')|int < 12 %} + Good morning. + {% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %} + Good afternoon. + {% else %} + Good evening. + {% endif %} +
+ + {% if is_state('binary_sensor.morning','on') %} ++ Today is {{ states.sensor.today_is.state }}, {{ as_timestamp(now()) | timestamp_custom('%B %d %Y') }}. +
+ {% else %} ++ It is {{ now().strftime("%I:%M %p") }} +
+ {% endif %} + ++ The weather in Defiance 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_studio.state }} + {% endif %} + + {% if states.sensor.weatheralerts_active_alerts.state | int > 0 %} + There are currently {{ states.sensor.weatheralerts_active_alerts.state }} active weather alerts for our area. + {% endif %} +
+ ++ {% if is_state('sun.sun','below_horizon') %} + You have + {% set seconds = as_timestamp(states.sun.sun.attributes.next_rising)-now().timestamp() %} + {% set hours = seconds / 60 %} + {% if seconds / ( 60 * 60 ) > 1 %} + {{ (seconds // ( 60 * 60 )) | int }} hours + {% else %} + {{ (seconds // 60) | int }} minutes + {% endif %} + {{ [ + 'until the sun rises.', + 'until the sun is up', + 'before the sun officially rises.' + ] | random }} + {% else %} + You have + {% set seconds = as_timestamp(states.sun.sun.attributes.next_setting)-now().timestamp() %} + {% set hours = seconds / 60 %} + {% if seconds / ( 60 * 60 ) > 1 %} + {{ (seconds // ( 60 * 60 )) | int }} hours + {% else %} + {{ (seconds // 60) | int }} minutes + {% endif %} + {{ [ + 'until the sun sets for the day.', + 'until the sun slips below the horizon.', + 'before the sun officially sets. ' + ]|random }} + {% endif %} +
+ + {% set dow = as_timestamp(now()) | timestamp_custom('%A') %} +
+ Let me check the sit rep for today.
+
+ {% if is_state('input_boolean.kallen_school','on') %}
+ Kallen is at school right now.
+ {% elif is_state('input_boolean.school_today','off') and is_state('input_boolean.school_in_session','on') %}
+ Kallen does not have school today.
+ {% endif %}
+
+ {% if is_state('person.christina_stork','Chipotle') and is_state('input_boolean.work_today','on') %}
+ Tina is at work right now.
+ {% elif is_state('input_boolean.work_today','on') %}
+ Tina has work today.
+ {% endif %}
+
+ {% if dow == 'Monday' %}
+ {{ [
+ 'Do not forget to take the trash bin to the curb, tomorrow is trash pickup day.',
+ 'Make sure to take the trash out. No, I do not mean Tony.',
+ 'Tomorrow is a big day for the garbage men. Make sure you do not let them down! Take the trash out!'
+ ] | random }}
+ {% endif %}
+
+ {% if dow == 'Tuesday' %}
+ {% if is_state('binary_sensor.evening','on') %}
+ {{ [
+ 'Do not forget to bring the trash can back from the curb.',
+ 'The trash can will feel lonely if you leave it at the curb all night.'
+ ] | random }}
+ {% endif %}
+ {% endif %}
+
+ {% if is_state('binary_sensor.evening','on') %}
+ {% if states.sensor.halloween_countdown.state | int == 1 %}
+ Tomorrow is Halloween. I hope you have picked out a costume. I will be going as Tony. I'm scared just thinking about it!
+ {% elif states.sensor.halloween_countdown.state | int < 30 %}
+ There are only {{states.sensor.halloween_countdown.state}} days
+ {{ [ 'until Halloween.',
+ 'until Halloween. It might not be enough time.',
+ 'until you need a costume.'
+ ] | random }}
+ {% else %}
+ {% endif %}
+
+ {% if states.sensor.christmas_countdown.state | int == 1 %}
+ Tomorrow is Christmas. Pickup today will be at {{(state_attr('input_datetime.school_day_end', 'timestamp') | int | timestamp_custom('%I:%M %p', False)) }}
+ {% if 'Early Release' in states('sensor.school_event') %}
+ And It is early release!
+ {% endif %}
+ {% endif %}
+ {% if states.sensor.school_end_days2go.state | int <= 35 and states.sensor.school_end_days2go.state | int > 0 %}
+ {{ [ 'Oh, and look at that.',
+ 'For those trying to keep count. ',
+ 'In case you were wondering.',
+ 'Also, did you know.'
+ ] | random }}
+ There are only {{ states.sensor.school_end_days2go.state }} days left in the school year!
+ {% endif %}
+ {% if states.sensor.school_end_days2go.state | int == -1 -%}
+ Today is the first day of Summer Break!
+ {%- endif %}
+ {% endif %}
+
+
+ Around the house, there are currently {{ states.sensor.current_lights_on.state }} lights on. +
+ + {%- 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