Merge branch 'welcome-home'

This commit is contained in:
2022-08-29 20:09:01 -04:00
3 changed files with 120 additions and 1 deletions

View File

@ -228,4 +228,20 @@ script:
- service: script.status_annc
data_template:
who: 'everywhere'
call_dinner_is_ready: 1
call_dinner_is_ready: 1
welcome_home:
sequence:
- condition: state
entity_id: input_boolean.welcome_home
state: 'on'
- wait_template: "{{ is_state('binary_sensor.front_door','on') }}"
timeout:
minutes: 5
continue_on_timeout: false
- delay:
seconds: 5
- service: script.speech_engine
data_template:
who: living_room
message: !include ../templates/speech/welcome_home.yaml

View File

@ -276,6 +276,7 @@ script:
entity_id: switch.presence_simulation
data: {}
- service: script.security_disarm
- service: script.welcome_home
- service: switch.turn_off
target:
entity_id:

View File

@ -0,0 +1,102 @@
>
{# 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>
As you are no doubt aware, 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 off. "
{% 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 %}
"The first floor thermostat refuses to be my friend. I am very sad about this. I mean, who the hell is Honeywell anyway? "
</p>
<p>
{% if is_state('light.living_room_lights','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. "
{% 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()) -}}