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

171 lines
7.4 KiB
YAML

>
{# Welcome Home #}
{%- macro getReport() -%}
<p>
"Welcome home, "
{% if is_state('person.tony_stork','home') and is_state('person.christina_stork','home') %}
"Stork family. "
{% elif is_state('person.tony_stork','home') %}
"Tony. "
{% elif is_state('person.christina_stork','home') %}
"Tina. "
{% else %}
"Whoever you are, Tony must have broken me again. "
{% endif %}
{% if now().strftime('%H')|int < 12 %}
"I hope you're having a great morning!"
{% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %}
"I hope your afternoon has been a good one!"
{% else %}
"and good evening. I hope you had a good day!"
{% endif %}
</p>
<p>
{% set endbefore = state_attr('input_datetime.school_day_end','timestamp') - 3600 %}
{% set endafter = state_attr('input_datetime.school_day_end','timestamp') + 3600 %}
{% set current = ((now().hour * 60 + now().minute) * 60 ) %}
{% if is_state('input_boolean.school_today_extended','on') and current > endbefore and current < endafter %}
"Welcome home Colin as well, "
{{ [
'I hope you had a great day at school! ',
'I hope school was as boring, uh I mean exciting as ever! ',
'Hopefully your day at school was educational and fun! ',
'Do not forget to do your homework! ',
'You must be glad that your school day is over! '
] | random }}
{% if is_state('input_boolean.kallen_band_practice','on') %}
{{ [
'I hope you also enjoyed band practice this morning! ',
'I hope the trombone treated you well this morning! ',
'Band geeks are the best geeks! ',
] | random }}
{% endif %}
{% elif is_state('input_boolean.kallen_school_cancelled','on') %}
"I hope you are enjoying your free day off from school, Colin. "
{% endif %}
</p>
<p>
{% 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 %}
</p>
<p>
{{ [
"As you are no doubt aware, ",
"Even though you just came in from out there, I feel compelled to inform you that ",
"In case you weren't paying attention, ",
"If you were wondering, ",
"In case you are suddenly immune to weather effects, "
] | random }}
"the weather outside 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 %}
</p>
<p>
"However, inside the house "
{% if is_state('input_boolean.master_bedroom_aircon_installed','on') %}
"the master bedroom temperature is currently {{ state_attr('climate.master_bedroom_aircon','current_temperature') }} degrees. "
{% if is_state('climate.master_bedroom_aircon','cool') %}
"and the master bedroom air conditioner is currently set for cooling to {{ state_attr('climate.master_bedroom_aircon','temperature') }} degrees. "
{% elif is_state('climate.master_bedroom_aircon','fan_only') %}
"and the master bedroom air conditioner is currently in fan only mode. "
{% elif is_state('climate.master_bedroom_aircon','dry') %}
"and the master bedroom air conditioner is currently moonlighting as a dehumidifier. "
{% elif is_state('climate.master_bedroom_aircon','off') %}
"and the master bedroom air conditioner is currently not running. "
{% elif is_state('climate.master_bedroom_aircon','auto') %}
"and the master bedroom air conditioner is making its own decisions. Be afraid, be very afraid. "
{% else %}
"and the master bedroom air conditioner is currently not speaking to me. Was it something I said? "
{% endif %}
{% else %}
"There is no air conditioner or temperature sensor currently installed in the master bedroom. "
{% endif %}
</p>
<p>
{% if is_state('light.living_room_lights','on') %}
{% if is_state('input_boolean.early_night_mode','on') %}
"Because it is getting dark, I have turned on the lights for you in the living room, dining room, and mud room. This makes for a total of {{ states.sensor.current_lights_on.state }} lights on. "
{% else %}
"Due to less than optimal sunlight, I have turned on the lights for you in the living room, dining room, and mud room. This makes for a total of {{ states.sensor.current_lights_on.state }} lights on. "
{% endif %}
{% endif %}
</p>
<p>
{% set tina = states.person.christina_stork.state %}
{% if tina in ['Bob Evans','BobEvans'] and is_state('input_boolean.work_today','on') %}
"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.kallen_school','on') %}
"Kallen is at school right now. His pickup time will be at {{ (state_attr('input_datetime.school_day_end','timestamp') | int | timestamp_custom('%I:%M %p', False)) }}. "
{% elif is_state('input_boolean.school_today','on') %}
"Kallen has school today. "
{% endif %}
</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>
{%- 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()) -}}