> {# 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_station.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 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 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 Colin!
{% 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'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. Tina is at work right now. She will be done at approximately {{ (state_attr('input_datetime.tina_workday_end','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}.
{% 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 Colin!
{% 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.Tina is at work right now. She will be done at approximately {{ (state_attr('input_datetime.tina_workday_end','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}.
{% elif is_state('input_boolean.work_today','on') %}
Tina has work today.
{% endif %}
{% if is_state('input_boolean.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.',
'Colin has school today.',
'It is a school day. '
] | random }}
{% if is_state('input_boolean.kallen_two_hour_delay','on') %}
'But there was a two hour delay. '
{% endif %}
{% if is_state('input_boolean.kallen_band_practice','on') %}
'And there is band practice before school this morning. '
{% endif %}
{% endif %}
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 is_state('input_boolean.kallen_school_cancelled','on') %}
'School has been cancelled for today. '
{% 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 %}
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()) -}}