> {# Script Name Here #} {%- 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 %}
{%- 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()) -}}