> {# 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 online 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') %} "Colin has school tomorrow, and there will be band practice in the morning at {{ as_timestamp(strptime(state_attr('calendar.kallen_school_days','start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%I:%M %p") }}. " {% else %} "Colin has school tomorrow at {{ as_timestamp(strptime(state_attr('calendar.kallen_school_days','start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%I:%M %p") }}. " {% endif %} {% else %} "Colin does not have school tomorrow. " {% endif %} {% if is_state('input_boolean.work_today','on') and states('person.christina_stork') in ['Bob Evans','BobEvans'] %} "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 at {{ (state_attr('input_datetime.tina_workday_start','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. " {% elif is_state('input_boolean.work_today','off') and is_state('sensor.work_tomorrow','on') %} "Tina has work tomorrow at {{ as_timestamp(strptime(state_attr('calendar.family_tinawork','start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%I:%M %p") }}. " {% elif is_state('input_boolean.work_today','off') and is_state('sensor.work_tomorrow','off') %} "Tina appears to have tomorrow off from work. " {% else %} "Tony is an idiot and appears to have broken my awareness of Tina's schedule. Boo this man. " {% endif %}
{% if is_state('sensor.garbage_collection_large_pickup','1') %} 'Tomorrow is the monthly unlimited garbage pickup. Make sure to take out all large garbage items tonight, and do not forget the trash can!' {% elif is_state('sensor.garbage_collection','1') %} {{ [ '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 %} {% set gc = state_attr('sensor.garbage_collection','days') %} {% if gc == 7 %} {{ [ '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 %}
"Bedroom climate scheduling will be as follows. " {% if is_state('input_boolean.master_bedroom_aircon_installed','on') %} {% if is_state('climate.master_bedroom_aircon','fan_only') %} "The master bedroom air conditioner is already running in fan only mode. " {% elif states('climate.master_bedroom_aircon') not in ['off','unknown','unavailable'] %} "The master bedroom air conditioner is already running in {{ states('climate.master_bedroom_aircon') }} mode. " {% elif is_state('input_select.scheduled_climate_mode_master_bedroom_aircon','AC') and is_state('input_boolean.hot_day','on') %} "Today was a hot day, so the master bedroom air conditioner will activate cooling mode a bit earlier tonight 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','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','N/A') %} "The master bedroom air conditioner will remain inactive tonight. " {% endif %} {% endif %} {% if is_state('fan.master_bedroom_fan_socket_1','on') %} "The master bedroom fan is already running. " {% elif 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','N/A') %} "The master bedroom fan will remain inactive tonight. " {% endif %} {% if is_state('input_boolean.kallen_overnight','off') %} {% if is_state('fan.kallen_fan_socket_1','on') %} "Colins fan is already running. " {% elif is_state('input_boolean.white_noise_kallen_bedroom','on') %} "Colins white noise generator is already running. " {% elif is_state('input_select.scheduled_climate_mode_kallen_fan','Fan') %} "Colins 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') %} "Colins 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','N/A') %} "Colins room will have no devices activated tonight. " {% endif %} {% else %} "Colins room will be left alone, as he is spending the night elsewhere tonight. " {% endif %} {% if is_state('fan.nursery_air_conditioner','on') %} "Emma's air conditioner is already running. " {% elif is_state('input_boolean.white_noise_emma_bedroom','on') %} "Emma's white noise generator is already running. " {% elif 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','N/A') %} "Emma's room will have no devices activated tonight. " {% endif %}
{% set windows = states('sensor.windows_open') %} {% set doors = states('sensor.doors_open') %} {% if states('sensor.total_faults') > '0' %} {% 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 %} "You will want to close these before the security system is armed for the night. " {% endif %}
{% 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 %}
{%- 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()) -}}