Finally got around to adding the Mother of all Macros from @thejeffreystone - https://github.com/thejeffreystone/home-assistant-configuration/pull/73 - Updated to handle underscores now.

This commit is contained in:
ccostan 2020-06-08 15:27:38 -04:00
parent 94bbce0a10
commit 6908244972

View File

@ -92,7 +92,7 @@
{%- endmacro -%} {%- endmacro -%}
{%- macro garage_check() -%} {%- macro garage_check() -%}
{% if states.group.garadget.state !='closed' -%} {% if states.group.garage_doors.state !='closed' -%}
The The
{%- for state in states.cover -%} {%- for state in states.cover -%}
{%- endfor %} {%- endfor %}
@ -220,10 +220,19 @@
{{inspirational_quote|random}} {{inspirational_quote|random}}
{% endmacro %} {% endmacro %}
{# a macro that removes all newline characters, empty spaces, and returns formatted text and replaces underscores with spaces #}
{%- macro cleanup(data) -%}
{%- for item in data.split("\n") if item | trim != "" -%}
{{ item | trim | replace("_", " ") }} {% endfor -%}
{%- endmacro -%}
{# ********************************************* #} {# ********************************************* #}
{# ******** Start the Speech routines ******** #} {# ******** Start the Speech routines ******** #}
{# ********************************************* #} {# ********************************************* #}
{# a macro to call all macros :) #}
{%- macro mother_of_all_macros() -%}
{% if call_no_announcement != 1 %} {% if call_no_announcement != 1 %}
{% if now().strftime('%H')|int < 12 and now().strftime('%H')|int > 6 %} {% if now().strftime('%H')|int < 12 and now().strftime('%H')|int > 6 %}
Good morning. Good morning.
@ -288,3 +297,6 @@
{# call a Random fact about the house or inspiration quote #} {# call a Random fact about the house or inspiration quote #}
{{ ([iss, moon, uv, holiday, days_until, outside_weather, outside_weather, inspirational_quote]|random)() }} {{ ([iss, moon, uv, holiday, days_until, outside_weather, outside_weather, inspirational_quote]|random)() }}
{%- endmacro -%}
{{- cleanup(mother_of_all_macros()) -}}