Made a daily briefing

This commit is contained in:
2022-05-22 17:52:58 -04:00
parent 7e7b965bf3
commit dcac49bb37
2 changed files with 324 additions and 1 deletions

View File

@ -87,6 +87,18 @@ automation:
action: action:
- service: script.kallen_nightly_briefing - 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: script:
reset_annc_switches: reset_annc_switches:
sequence: sequence:
@ -134,4 +146,11 @@ script:
- service: script.text_notify - service: script.text_notify
data: data:
who: "ios_parents" who: "ios_parents"
message: "I just gave Kallen's morning briefing" 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

View File

@ -0,0 +1,304 @@
>
{# Daily Briefing #}
{%- macro getReport() -%}
<p>
{% 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 %}
</p>
{% if is_state('binary_sensor.morning','on') %}
<p>
Today is {{ states.sensor.today_is.state }}, {{ as_timestamp(now()) | timestamp_custom('%B %d %Y') }}.
</p>
{% else %}
<p>
It is {{ now().strftime("%I:%M %p") }}
</p>
{% endif %}
<p>
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 %}
</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>
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. <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 Kallen, 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 }}
{% else %}
{% endif %}
{% if states.sensor.anniversary_wedding_anniversary.state | int == 1 %}
Tomorrow is Tony and Christina's wedding anniversary!
{% 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 %}
{%- 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 Pepporini 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 camera looking at the drive way 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. <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 -%}
{% if is_state('input_boolean.school_today', 'on') and state_attr('input_datetime.school_day_end', 'timestamp') < as_timestamp(now()) %}
{% 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.',
'Kallen has school today.',
'It is a school day. '
] | random }}
{% endif %}
<s>Pickup today will be at {{(state_attr('input_datetime.school_day_end', 'timestamp') | int | timestamp_custom('%I:%M %p', False)) }}</s>
{% 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 %}
</p>
<p>
Around the house, there are currently {{ states.sensor.current_lights_on.state }} lights on.
</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()) -}}