diff --git a/packages/announcements.yaml b/packages/announcements.yaml index d1fb613..a2a33a3 100644 --- a/packages/announcements.yaml +++ b/packages/announcements.yaml @@ -228,4 +228,20 @@ script: - service: script.status_annc data_template: who: 'everywhere' - call_dinner_is_ready: 1 \ No newline at end of file + 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 \ No newline at end of file diff --git a/packages/presence.yaml b/packages/presence.yaml index 0fcac55..b5976a2 100644 --- a/packages/presence.yaml +++ b/packages/presence.yaml @@ -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: diff --git a/templates/speech/welcome_home.yaml b/templates/speech/welcome_home.yaml new file mode 100644 index 0000000..27a7641 --- /dev/null +++ b/templates/speech/welcome_home.yaml @@ -0,0 +1,102 @@ +> + {# Welcome Home #} + {%- macro getReport() -%} +

+ "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 %} +

+ +

+ 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 %} +

+ +

+ "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? " +

+ +

+ {% 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 %} +

+ + {%- 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()) -}} \ No newline at end of file