home-assistant-configuration/templates/traffic_report.yaml

29 lines
823 B
YAML

>
{% macro getIntro() %}
Under current traffic conditions
{% endmacro %}
{% macro getTrafficZoo() %}
Zoo Atlanta is {{states.sensor.home_to_zoo.state|round}} minutes away
{% endmacro %}
{% macro getTrafficCox() %}
And Cox Automotive is {{states.sensor.home_to_summit.state|round}} minutes away by car.
{% 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() -%}
{{ getTrafficZoo() }}
{{ getTrafficCox() }}
{%- endmacro -%}
{# Call the macro #}
{{- cleanup(mother_of_all_macros()) -}}