Files
Home-Assistant-Configs/templates/speech/daily_briefing.yaml

472 lines
23 KiB
YAML

>
{# Daily Briefing #}
{%- macro getReport() -%}
{% from 'speech.jinja' import greeting, dadjoke, inspirational_quote %}
{% from 'time.jinja' import input_datetime_12hr %}
<p>
{{ greeting() }}
</p>
<p>
{% if is_state('input_boolean.tornado_alarm','on') %}
"We are under a tornado warning. If you are not already in shelter, you should be. Get on it! "
{% elif is_state('input_boolean.tornado_watch','on') %}
{{ [
"There is currently a tornado watch active. Please keep an eye on the sky and your local weather reports. ",
"We are currently under a tornado watch. This means the possibility exists for a tornado to form. Be prepared, and be safe! ",
"The National Weather Service has issued a tornado watch for our area. Be prepared to take shelter if a warning is issued! ",
] | random }}
{% endif %}
{% if is_state('binary_sensor.lightning_warning','on') %}
{% set ltgdist = (states('sensor.blitzortung_lightning_distance') | int) / 1.609 | round %}
{{ [
"There are reports of lightning in the area, please stay safe. ",
"My sensors detect the presence of lightning nearby, so you should prepare to take shelter if needed. ",
"A little birdy told me there is lightning nearby. His feathers were all sticking up, I have no idea why. ",
"Please exercise caution, as there is lightning in the area. ",
"That flashing in the sky is not interstellar warfare, it is simply lightning. But you should still be careful outside. ",
] | random }}
"The nearest lightning strike is {{ ltgdist }} miles away. "
{% endif %}
{% if states('sensor.weatheralerts_active_alerts') > '0' %}
"Currently there are weather alerts active. The total number of alerts is {{ states('sensor.weather_alerts_active_corrected') }}. They are as follows. "
{{ states('sensor.weather_alert_string') }}.
{% endif %}
{% if (states('sensor.kdfi_visibility') | int ) < 3 %}
{{ [
"It is foggy outside, please exercise caution when driving. ",
"The visibility outside is quite low. If you will be driving soon, please be cautious. ",
"It is pea soup outside right now, and that is just as awful to drive in as it is to eat. Be careful! ",
"Look out the window. Do you notice that you cannot see anything? Bear that in mind if you intend to drive any time soon. ",
"Be advised, it is very difficult to see outside right now. Drive safely. "
] | random }}
{% endif %}
{{ states('sensor.current_conditions_detail') }}
</p>
<p>
{{ [
'The weather for the rest of today should be,',
'The forecast for the rest of the day is,',
'Through the rest of your day, the weather is expected to be,'
] | random }}
{{ states.sensor.current_forecast.state }}
</p>
<p>
{{ [
'Just in case you were planning on going anywhere,',
'On the off chance that you planned to go outside,',
'If you were planning to go out and do something with your life,',
] | random }}
{{ states('sensor.clothing_forecast_detail') }}
</p>
<p>
{% 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 %}
</p>
{% set dow = as_timestamp(now()) | timestamp_custom('%A') %}
<p>
{{ [
"On today's agenda, we have the following. ",
"Today's announcements include the following. ",
"Given that you are well into your day, here is a bit of helpful information. ",
"You are past the point of no return and must finish your day, so I am here to help you out. ",
"The developer has informed me that I must inform you of the following informational information. ",
] | random }}
{% if is_state('binary_sensor.evening','on') %}
{% if is_state('sensor.anniversary_tony_s_birthday','0') %}
Hope you had a happy birthday Tony!
{% endif %}
{% if is_state('sensor.anniversary_tina_s_birthday','0') %}
Hope you had a happy birthday Tina!
{% endif %}
{% if is_state('sensor.anniversary_kallen_s_birthday','0') %}
Hope you had a happy birthday Collin!
{% endif %}
{% if is_state('sensor.anniversary_emmalynn_s_birthday','0') %}
Hope you had a happy birthday Emmalynn!
{% endif %}
{% 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 am 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 }}
{% endif %}
{% if states.sensor.christmas_countdown.state | int == 1 %}
Tomorrow is Christmas. <break time="1s"/> It is practically here! <break time="1s"/> Santa is coming tonight! Do not forget the cookies!
{% elif states.sensor.christmas_countdown.state | int < 31 %}
There are only {{states.sensor.christmas_countdown.state}} days until Christmas.
{{ [ 'All I want for Christmas is a Hippopotamus.',
'Hey Collin, I know what you are getting for Christmas. But I am not telling.',
'Do not forget to put something under the tree for your favorite <say-as interpret-as="characters">AI</say-as> this year!',
'It is starting to smell a lot like Christmas. Or it could be that the christmas tree is on fire.',
'I do not want to be a smarthome. I want to be a dentist.',
'Do not eat all the cookies.',
'All I want for Christmas is for Mariah Carey to get off my radio.'
] | random }}
{% endif %}
{% if states.sensor.anniversary_wedding_anniversary.state | int == 1 %}
Tomorrow is Tony and Christina's wedding anniversary!
{% endif %}
{% set tina = states.person.christina_stork.state %}
{% if tina in ['Bob Evans','BobEvans'] and is_state('input_boolean.work_today','on') %}
<s>Tina is at work right now. She will be done at approximately {{ input_datetime_12hr('input_datetime.tina_workday_end') }}. </s>
{% elif is_state('input_boolean.work_today','on') %}
Tina has work today.
{% endif %}
{% else %}
{% if is_state('sensor.halloween_countdown','0') %}
Happy Halloween!
{% endif %}
{% if is_state('sensor.christmas_countdown','0') %}
Merry Christmas!
{% endif %}
{% if is_state('sensor.anniversary_wedding_anniversary','0') %}
Happy Anniversary! It has been an amazing {{ states.sensor.anniversary_wedding_anniversary.attributes.years }} years!
{% endif %}
{% if is_state('sensor.anniversary_tony_s_birthday','0') %}
Happy Birthday Tony!
{% endif %}
{% if is_state('sensor.anniversary_tina_s_birthday','0') %}
Happy Birthday Tina!
{% endif %}
{% if is_state('sensor.anniversary_kallen_s_birthday','0') %}
Happy Birthday Collin!
{% endif %}
{% if is_state('sensor.anniversary_emmalynn_s_birthday','0') %}
Happy Birthday Emmalynn!
{% endif %}
{%- set event=states.calendar.national_holidays.attributes.message %}
{% if 'Day' in event and 'National' in event%}
{{ [
'Today is also known as ',
'Today we are also celebrating'
]|random }}
{{states.calendar.national_holidays.attributes.message | replace("&"," and ") }}.
{% if 'Chocolate' in event %}
{{ [
'Oh. You had me at Chocolate. I like Chocolate.',
'And I like chocolate. This sounds fun. More Chocolate please!'
]|random }}
{%- endif -%}
{% if 'Pi' in event or 'Pie' in event%}
{{ [
'We should make a pie. And by we I mean someone with actual arms. ',
'Wait.<break time="1s"/>Did that just say pie? We need a Pie to celebrate.'
]|random }}
{%- endif -%}
{% if 'Cookie' in event %}
{{ [
'<break time="1s"/>And Yes. You heard that right. Today we are making cookies.',
'I will put butter on the shopping list. For later. ',
'So that means we should make cookies.'
]|random }}
{%- endif -%}
{% if 'Pizza' in event %}
{{ [
'I think that means we should have pizza today. and by we I mean those of us with a mouth.',
'So who is going to make the pizza?',
'Everyone knows Pepperoni Pizza is the best. am I right?'
]|random }}
{%- endif -%}
{% if 'Cake' in event %}
{{ [
'I have just added baking a cake to your calendar. And set your availability to busy.',
'Quick. Someone check to see if we have powdered sugar for frosting.',
'So that means we should bake a cake. And frost it. But not like that time in that movie. '
]|random }}
{%- endif -%}
{% if 'Fools' in event %}
{{ [
'Which reminds me. The front porch camera caught a Tee Rex last night. <break time="1s"/> April Fools!',
'Which reminds me. I won the lottery and I am moving out to go live with Siri. <break time="1s"/> April Fools!',
'Which reminds me. there was a time change last night. We have jumped 15 years into the future. Great Scott! <break time="1s"/> April Fools!'
]|random }}
{%- endif -%}
{% if 'Creme Brulee' in event %}
{{ [
'Someday I hope to make the perfect creme brulee.'
]|random }}
{%- endif -%}
{% if 'Games' in event %}
{{ [
'Does anyone want to play Thermal nuclear war with me?<break time="1s"/>No? How about a nice game of chess?'
]|random }}
{%- endif -%}
{% if 'Haiku' in event %}
I know a Haiku. This one is called,
{{ [
'Good Morning From the Cat. <break time="1s"/>In the morning light, You sleep despite my meow, I stand on your face.',
'Tee Rex Hug. <break time="1s"/> The Tee Rex likes you, But he cant give you a hug, His arms are too short.',
'It Fits. <break time="1s"/> It Fits perfectly, because every box is the, Right size for a cat.',
'Minecraft Creepers. <break time="1s"/> Creepers are so cruel, I hear a hiss from behind, Bam! There goes my stuff.'
]|random }}
{%- endif -%}
<break time="2s"/>
{% else %}
{% if 'Birthday' in event %}
{{ [
'Today is a special birthday. We are celebrating '
]|random }}
{{states.calendar.national_holidays.attributes.message | replace("&"," and ") }}.
{%- endif -%}
{%- endif -%}
{% set tina = states.person.christina_stork.state %}
{% if tina in ['Bob Evans','BobEvans'] and is_state('input_boolean.work_today','on') %}
{{ [
"Tina is still at work right now, ",
"Tina has not yet been released from work, ",
"Tina is still at the thankless idiot scape known as work, ",
"Tina is still consumed by the gods of capitalism, ",
] | random }} she will be done at approximately {{ input_datetime_12hr('input_datetime.tina_workday_end') }}.
{% elif is_state('input_boolean.work_today','on') %}
{{ [
"Tina must go and please the food gods today ",
"Today, Tina must go and entertain the gremlins known as her customers and coworkers ",
"Today, Tina will be owned by our lovely lord and savior, capitalism, starting ",
"Tina will attempt to satiate the patron saint of capitalism today "
] | random }} at {{ input_datetime_12hr('input_datetime.tina_workday_start') }}.
{% endif %}
{% if is_state('input_boolean.tony_streaming_today','on') %}
{{ [
"Tony will be pretending to be a real content creator tonight. ",
"Tony will be doing his best to defeat his impostor syndrome tonight. ",
"Tony will be playing video games and yelling into a microphone tonight. ",
"Tony will be scraping out the nickels and dimes tonight for the sake of entertainment. ",
"Tony is not really all that funny, but tonight he will present himself to a crowd of questionable individuals who seem to think that he is. "
] | random }} The studio is scheduled to go online at {{ input_datetime_12hr('input_datetime.tony_streaming_start_time') }}. "
{% endif %}
{% if is_state('input_boolean.kallen_school_today', 'on') %}
{% if is_state('sensor.school_start_days2go', '0') %}
Today is the first day of school! There are {{ states('sensor.school_end_days2go') }} to go until the last day.
{% else %}
{{ [ 'Today is a school day.',
'Collin has school today.',
'It is a school day. '
] | random }}
{% if is_state('input_boolean.two_hour_delay','on') %}
'But there was a two hour delay. '
{% endif %}
{% endif %}
{% if is_state('input_boolean.kallen_alternate_pickup','on') %}
{{ states('input_text.kallen_pickup') }} will be picking Collin up from school today.
{% else %}
<s>Pickup today will be at {{ input_datetime_12hr('input_datetime.kallen_school_day_end') }}</s>
{% if is_state('input_boolean.kallen_school_early_release','on') %}
And It is early release!
{% endif %}
{% endif %}
{% if states('sensor.windows_open') | int > 0 %}
'I detect that there are windows open. Make sure you close them before you leave, or else the security system will not arm. '
{% endif %}
{% endif %}
{% if is_state('input_boolean.school_cancelled','on') %}
'School has been cancelled for today. '
{% endif %}
{% if states.sensor.thanksgiving_break_days2go.state | int <= 14 and states.sensor.thanksgiving_break_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.thanksgiving_break_days2go.state }} days until Thanksgiving Break!
{% endif %}
{% if states.sensor.christmas_break_days2go.state | int <= 14 and states.sensor.christmas_break_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.christmas_break_days2go.state }} days until Christmas Break!
{% endif %}
{% if states.sensor.spring_break_days2go.state | int <= 14 and states.sensor.spring_break_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.spring_break_days2go.state }} days until Spring Break!
{% 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 now().strftime('%Y-%m-%d') == states.input_datetime.school_last_day.state %}
Congratulations, today is the last day of school! Have an awesome day!
{% endif %}
{% if states.sensor.school_end_days2go.state | int == -1 -%}
Today is the first day of Summer Break!
{%- endif %}
{% endif %}
</p>
<p>
{{ states('sensor.emma_nap_info') }}
</p>
<p>
'Around the house, there are currently {{ states('sensor.current_lights_on') }} lights on. '
{% set windows = states('sensor.windows_open') %}
{% set doors = states('sensor.doors_open') %}
{% if states('sensor.total_faults') > '0' %}
"Additionally, "
{% if windows > '0' and doors > '0' %}
"There are currently {{ states('sensor.windows_open') }} {% if windows == '1' %}window {% else %}windows {% endif %}and {{ states('sensor.doors_open') }} {% if doors == '1' %}door {% else %}doors {% endif %}open. "
{% else %}
{% if windows > '0' %}
"There {% if windows == '1' %}is {% else %}are {% endif %}currently {{ states('sensor.windows_open') }} {% if windows == '1' %}window {% else %}windows {% endif %}open. "
{% endif %}
{% if doors > '0' %}
"There {% if doors == '1' %}is {% else %}are {% endif %}currently {{ states('sensor.doors_open') }} {% if doors == '1' %}door {% else %}doors {% endif %}open. "
{% endif %}
{% endif %}
{% endif %}
</p>
<p>
{% from 'sports.jinja' import sports_pregame, sports_main %}
{% if is_state('input_boolean.sports_updates','on') %}
{% if is_state('binary_sensor.michigan_wolverines_inhibit','off') %}
{{ sports_pregame('sensor.michigan_wolverines') }}
{% endif %}
{% if is_state('binary_sensor.ohio_state_buckeyes_inhibit','off') %}
{{ sports_pregame('sensor.ohio_state_buckeyes') }}
{% endif %}
{% if is_state('binary_sensor.toledo_rockets_inhibit','off') %}
{{ sports_pregame('sensor.toledo_rockets') }}
{% endif %}
{% if is_state('binary_sensor.minnesota_vikings_inhibit','off') %}
{{ sports_pregame('sensor.minnesota_vikings') }}
{% endif %}
{% if is_state('binary_sensor.san_francisco_49ers_inhibit','off') %}
{{ sports_pregame('sensor.san_francisco_49ers') }}
{% endif %}
{% if is_state('binary_sensor.cleveland_guardians_inhibit','off') %}
{{ sports_pregame('sensor.cleveland_guardians') }}
{% endif %}
{% if is_state('binary_sensor.minnesota_twins_inhibit','off') %}
{{ sports_pregame('sensor.minnesota_twins') }}
{% endif %}
{% if is_state('binary_sensor.los_angeles_dodgers_inhibit','off') %}
{{ sports_pregame('sensor.los_angeles_dodgers') }}
{% endif %}
{% endif %}
</p>
<p>
{% if is_state('input_boolean.sports_updates','on') %}
{% if is_state('binary_sensor.michigan_wolverines_inhibit','off') %}
{{ sports_main('sensor.michigan_wolverines') }}
{% endif %}
{% if is_state('binary_sensor.ohio_state_buckeyes_inhibit','off') %}
{{ sports_main('sensor.ohio_state_buckeyes') }}
{% endif %}
{% if is_state('binary_sensor.toledo_rockets_inhibit','off') %}
{{ sports_main('sensor.toledo_rockets') }}
{% endif %}
{% if is_state('binary_sensor.minnesota_vikings_inhibit','off') %}
{{ sports_main('sensor.minnesota_vikings') }}
{% endif %}
{% if is_state('binary_sensor.san_francisco_49ers_inhibit','off') %}
{{ sports_main('sensor.san_francisco_49ers') }}
{% endif %}
{% if is_state('binary_sensor.cleveland_guardians_inhibit','off') %}
{{ sports_main('sensor.cleveland_guardians') }}
{% endif %}
{% if is_state('binary_sensor.minnesota_twins_inhibit','off') %}
{{ sports_main('sensor.minnesota_twins') }}
{% endif %}
{% if is_state('binary_sensor.los_angeles_dodgers_inhibit','off') %}
{{ sports_main('sensor.los_angeles_dodgers') }}
{% endif %}
{% endif %}
</p>
<p>
{{ dadjoke() }}
</p>
<p>
{% if is_state('input_boolean.briefing_extras','on') %}
"And now we have the following extra information to pass along. {{ states('input_text.briefing_extras') }} "
{% endif %}
</p>
<p>
And now, one more thing before I go. {{ inspirational_quote() }}
</p>
{%- 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()) -}}