Remove unnecessary repeated definitions of the cleanup macro

This commit is contained in:
2023-07-01 14:08:40 -04:00
parent 1c51c678e5
commit 529b24e310
16 changed files with 152 additions and 315 deletions

View File

@ -1,54 +1,62 @@
{% from 'formatting.jinja' import cleanup %}
{% macro sports_pregame(team) %} {% macro sports_pregame(team) %}
{% macro data() %}
{% if is_state(team,'PRE') %} {% if is_state(team,'PRE') %}
{% set date = state_attr(team,'date') | as_timestamp | timestamp_custom('%m-%d') %} {% set date = state_attr(team,'date') | as_timestamp | timestamp_custom('%m-%d') %}
{% if date == now().strftime('%m-%d') %} {% if date == now().strftime('%m-%d') %}
"The {{ state_attr(team,'friendly_name') }} will be playing today against the {{ state_attr(team,'opponent_name') }} at {{ state_attr(team,'venue') }}. " The {{ state_attr(team,'friendly_name') }} will be playing today against the {{ state_attr(team,'opponent_name') }} at {{ state_attr(team,'venue') }}.
"Start time is at {{ state_attr(team,'date') | as_timestamp | timestamp_custom('%I:%M %p') }}. " Start time is at {{ state_attr(team,'date') | as_timestamp | timestamp_custom('%I:%M %p') }}.
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endmacro%} {% endmacro%}
{{ cleanup(data()) }}
{% endmacro %}
{% macro sports_main(team) %} {% macro sports_main(team) %}
{% macro data() %}
{% if is_state(team,'POST') %} {% if is_state(team,'POST') %}
{% set date = state_attr(team,'date') | as_timestamp | timestamp_custom('%m-%d') %} {% set date = state_attr(team,'date') | as_timestamp | timestamp_custom('%m-%d') %}
{% set yday = (as_timestamp(now()) - (24*3600)) | timestamp_custom('%m-%d') %} {% set yday = (as_timestamp(now()) - (24*3600)) | timestamp_custom('%m-%d') %}
{% if date == now().strftime('%m-%d') %} {% if date == now().strftime('%m-%d') %}
{% if state_attr(team,'clock') in ['postponed','Postponed'] %} {% if state_attr(team,'clock') in ['postponed','Postponed'] %}
"The {{ state_attr(team,'friendly_name') }} had their game postponed today, and it will be played at a later date. " The {{ state_attr(team,'friendly_name') }} had their game postponed today, and it will be played at a later date.
{% elif (state_attr(team,'team_score') | int) == state_attr(team,'opponent_score') | int %} {% elif (state_attr(team,'team_score') | int) == state_attr(team,'opponent_score') | int %}
"The {{ state_attr(team,'friendly_name') }} tied in their game today against the {{ state_attr(team,'opponent_name') }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. " The {{ state_attr(team,'friendly_name') }} tied in their game today against the {{ state_attr(team,'opponent_name') }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}.
{% elif state_attr(team,'team_winner') == true %} {% elif state_attr(team,'team_winner') == true %}
"The {{ state_attr(team,'friendly_name') }} won their game today against the {{ state_attr(team,'opponent_name') }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. " The {{ state_attr(team,'friendly_name') }} won their game today against the {{ state_attr(team,'opponent_name') }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}.
{% elif state_attr(team,'opponent_winner') == true %} {% elif state_attr(team,'opponent_winner') == true %}
"The {{ state_attr(team,'friendly_name') }} lost their game today against the {{ state_attr(team,'opponent_name') }} by a score of {{ state_attr(team,'opponent_score') }} to {{ state_attr(team,'team_score') }}. " The {{ state_attr(team,'friendly_name') }} lost their game today against the {{ state_attr(team,'opponent_name') }} by a score of {{ state_attr(team,'opponent_score') }} to {{ state_attr(team,'team_score') }}.
{% endif %} {% endif %}
{% if state_attr(team,'clock') not in ['postponed','Postponed'] %} {% if state_attr(team,'clock') not in ['postponed','Postponed'] %}
"This brings their record to {{ state_attr(team,'team_record') | replace("-"," and ") }} on the season. " This brings their record to {{ state_attr(team,'team_record') | replace("-"," and ") }} on the season.
{% endif %} {% endif %}
{% elif yday == date %} {% elif yday == date %}
{% if state_attr(team,'clock') in ['postponed','Postponed'] %} {% if state_attr(team,'clock') in ['postponed','Postponed'] %}
"The {{ state_attr(team,'friendly_name') }} had their game postponed yesterday, and it will be played at a later date. " The {{ state_attr(team,'friendly_name') }} had their game postponed yesterday, and it will be played at a later date.
{% elif (state_attr(team,'team_score') | int) == state_attr(team,'opponent_score') | int %} {% elif (state_attr(team,'team_score') | int) == state_attr(team,'opponent_score') | int %}
"The {{ state_attr(team,'friendly_name') }} tied in their game yesterday against the {{ state_attr(team,'opponent_name') }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. " The {{ state_attr(team,'friendly_name') }} tied in their game yesterday against the {{ state_attr(team,'opponent_name') }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}.
{% elif state_attr(team,'team_winner') == true %} {% elif state_attr(team,'team_winner') == true %}
"The {{ state_attr(team,'friendly_name') }} won their game yesterday against the {{ state_attr(team,'opponent_name') }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. " The {{ state_attr(team,'friendly_name') }} won their game yesterday against the {{ state_attr(team,'opponent_name') }} by a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}.
{% elif state_attr(team,'opponent_winner') == true %} {% elif state_attr(team,'opponent_winner') == true %}
"The {{ state_attr(team,'friendly_name') }} lost their game yesterday against the {{ state_attr(team,'opponent_name') }} by a score of {{ state_attr(team,'opponent_score') }} to {{ state_attr(team,'team_score') }}. " The {{ state_attr(team,'friendly_name') }} lost their game yesterday against the {{ state_attr(team,'opponent_name') }} by a score of {{ state_attr(team,'opponent_score') }} to {{ state_attr(team,'team_score') }}.
{% endif %} {% endif %}
{% if state_attr(team,'clock') not in ['postponed','Postponed'] %} {% if state_attr(team,'clock') not in ['postponed','Postponed'] %}
"This brings their record to {{ state_attr(team,'team_record') | replace("-"," and ") }} on the season. " This brings their record to {{ state_attr(team,'team_record') | replace("-"," and ") }} on the season.
{% endif %} {% endif %}
{% endif %} {% endif %}
{% elif is_state(team,'IN') %} {% elif is_state(team,'IN') %}
{% if (state_attr(team,'team_score') | int) == (state_attr(team,'opponent_score') | int) %} {% if (state_attr(team,'team_score') | int) == (state_attr(team,'opponent_score') | int) %}
"The {{ state_attr(team,'friendly_name') }} are currently tied in their game against the {{ state_attr(team,'opponent_name') }} with a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. " The {{ state_attr(team,'friendly_name') }} are currently tied in their game against the {{ state_attr(team,'opponent_name') }} with a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}.
{% elif (state_attr(team,'team_score') | int) > (state_attr(team,'opponent_score') | int) %} {% elif (state_attr(team,'team_score') | int) > (state_attr(team,'opponent_score') | int) %}
"The {{ state_attr(team,'friendly_name') }} are currently winning their game against the {{ state_attr(team,'opponent_name') }} with a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}. " The {{ state_attr(team,'friendly_name') }} are currently winning their game against the {{ state_attr(team,'opponent_name') }} with a score of {{ state_attr(team,'team_score') }} to {{ state_attr(team,'opponent_score') }}.
{% else %} {% else %}
"The {{ state_attr(team,'friendly_name') }} are currently losing their game against the {{ state_attr(team,'opponent_name') }} with a score of {{ state_attr(team,'opponent_score') }} to {{ state_attr(team,'team_score') }}. " The {{ state_attr(team,'friendly_name') }} are currently losing their game against the {{ state_attr(team,'opponent_name') }} with a score of {{ state_attr(team,'opponent_score') }} to {{ state_attr(team,'team_score') }}.
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{{ cleanup(data()) }}
{% endmacro %}
{% macro sports_inhibit(team) %} {% macro sports_inhibit(team) %}
{% if state_attr(team,'kickoff_in') %} {% if state_attr(team,'kickoff_in') %}

View File

@ -1,3 +1,4 @@
{% from 'formatting.jinja' import cleanup %}
{% from 'time.jinja' import input_datetime_read, ct, next_twitch_stream, calendar_event_today, time_from_calendar %} {% from 'time.jinja' import input_datetime_read, ct, next_twitch_stream, calendar_event_today, time_from_calendar %}
{% from 'easy_time.jinja' import count_the_days, custom_time, custom_time_between, clock %} {% from 'easy_time.jinja' import count_the_days, custom_time, custom_time_between, clock %}
{% from 'lighting.jinja' import lightsOn %} {% from 'lighting.jinja' import lightsOn %}
@ -57,6 +58,7 @@
{% endmacro %} {% endmacro %}
{% macro houseStatusReport(type,method) %} {% macro houseStatusReport(type,method) %}
{% macro data() %}
{% if type == 'climate_devices' %} {% if type == 'climate_devices' %}
{{ climateDevices(type,method) }} {{ climateDevices(type,method) }}
{% elif type == 'airleaks' %} {% elif type == 'airleaks' %}
@ -69,6 +71,8 @@
{{ airLeaks(type,method) }} {{ airLeaks(type,method) }}
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{{ cleanup(data()) }}
{% endmacro %}
{% macro twitchStreamInfo(type,method) %} {% macro twitchStreamInfo(type,method) %}
{% if is_state('input_boolean.tony_streaming_today','on') or calendar_event_today('calendar.tony_s_twitch_schedule') == 'false' %} {% if is_state('input_boolean.tony_streaming_today','on') or calendar_event_today('calendar.tony_s_twitch_schedule') == 'false' %}
@ -147,6 +151,7 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{% endmacro %} {% endmacro %}
{% macro tonyStatusReport(type,method) %} {% macro tonyStatusReport(type,method) %}
{% macro data() %}
{% if type == 'meds' %} {% if type == 'meds' %}
{{ medReportTony(type,method) }} {{ medReportTony(type,method) }}
{% endif %} {% endif %}
@ -158,6 +163,8 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{{ medReportTony(type,method) }} {{ medReportTony(type,method) }}
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{{ cleanup(data()) }}
{% endmacro %}
{% macro tina_morning_meds(type,method) %} {% macro tina_morning_meds(type,method) %}
{% if is_state('binary_sensor.overnight','off') %} {% if is_state('binary_sensor.overnight','off') %}
@ -268,6 +275,7 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{% endmacro %} {% endmacro %}
{% macro tinaStatusReport(type,method) %} {% macro tinaStatusReport(type,method) %}
{% macro data() %}
{% if type == 'work' %} {% if type == 'work' %}
{{ workReportTina(type,method) }} {{ workReportTina(type,method) }}
{% elif type == 'meds' %} {% elif type == 'meds' %}
@ -277,6 +285,8 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{{ medReportTina(type,method) }} {{ medReportTina(type,method) }}
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{{ cleanup(data()) }}
{% endmacro %}
{% macro kallen_morning_meds(type,method) %} {% macro kallen_morning_meds(type,method) %}
{% set wakeup = state_attr('input_datetime.kallen_wakeup_time','timestamp') | int %} {% set wakeup = state_attr('input_datetime.kallen_wakeup_time','timestamp') | int %}
@ -447,6 +457,7 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{% endmacro %} {% endmacro %}
{% macro kallenStatusReport(type,method) %} {% macro kallenStatusReport(type,method) %}
{% macro data() %}
{% if type == 'meds' %} {% if type == 'meds' %}
{{ medReportKallen(type,method) }} {{ medReportKallen(type,method) }}
{% elif type == 'school' %} {% elif type == 'school' %}
@ -459,6 +470,8 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{{ schoolReportKallen(type,method) }} {{ schoolReportKallen(type,method) }}
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{{ cleanup(data()) }}
{% endmacro %}
{% macro emma_sleep(type,method) %} {% macro emma_sleep(type,method) %}
{% set asleep = state_attr('input_datetime.emma_down_for_nap','timestamp') | int %} {% set asleep = state_attr('input_datetime.emma_down_for_nap','timestamp') | int %}
@ -501,9 +514,12 @@ Tony is currently streaming. The current stream category is {{ game }}. The curr
{% endmacro %} {% endmacro %}
{% macro emmaStatusReport(type,method) %} {% macro emmaStatusReport(type,method) %}
{% macro data() %}
{% if type == 'sleep' %} {% if type == 'sleep' %}
{{ emma_sleep(type,method) }} {{ emma_sleep(type,method) }}
{% elif type == 'full' %} {% elif type == 'full' %}
{{ emma_sleep(type,method) }} {{ emma_sleep(type,method) }}
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{{ cleanup(data()) }}
{% endmacro %}

View File

@ -1,3 +1,4 @@
{% from 'formatting.jinja' import cleanup %}
{% from 'time.jinja' import ct %} {% from 'time.jinja' import ct %}
{% set ct = ct() | int %} {% set ct = ct() | int %}
@ -82,8 +83,11 @@
{% endmacro %} {% endmacro %}
{% macro weatherReport(type,method,time) %} {% macro weatherReport(type,method,time) %}
{% macro data() %}
{{ weatherInfo(type,method,time) | replace('clear-night','clear') | replace('partlycloudy','partly cloudy') }} {{ weatherInfo(type,method,time) | replace('clear-night','clear') | replace('partlycloudy','partly cloudy') }}
{% endmacro %} {% endmacro %}
{{ cleanup(data()) }}
{% endmacro %}
{% macro tempConvert(temp,unitFrom,unitTo) %} {% macro tempConvert(temp,unitFrom,unitTo) %}
{% if unitFrom in ['F','f'] %} {% if unitFrom in ['F','f'] %}

Submodule node-red/projects/NerdFlows updated: c8568f46e3...4985b28f0f

View File

@ -207,6 +207,7 @@ sensor:
unique_id: e5ae9864-70b5-402c-9d2f-c4d6a10085df unique_id: e5ae9864-70b5-402c-9d2f-c4d6a10085df
icon_template: mdi:weather-sunny icon_template: mdi:weather-sunny
value_template: >- value_template: >-
{% from 'formatting.jinja' import cleanup %}
{%- macro getReport() -%} {%- macro getReport() -%}
{{ [ {{ [
'Today in Defiance ', 'Today in Defiance ',
@ -310,18 +311,7 @@ sensor:
] | random }} ] | random }}
{{ states('sensor.overnight_lowest_temperature') }} degrees. {{ states('sensor.overnight_lowest_temperature') }} degrees.
{%- endmacro -%} {%- endmacro -%}
{# a macro that removes all newline characters, empty spaces, and returns formatted text #} {{- cleanup(getReport()) -}}
{%- 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()) -}}
tomorrow_forecast: tomorrow_forecast:
friendly_name: Tomorrows Forecast friendly_name: Tomorrows Forecast
unique_id: a8ae26b0-ed26-4568-bb2b-f7c72707b009 unique_id: a8ae26b0-ed26-4568-bb2b-f7c72707b009
@ -350,6 +340,7 @@ sensor:
unique_id: 21374ed0-80d1-49ba-817d-3e93eb3865e4 unique_id: 21374ed0-80d1-49ba-817d-3e93eb3865e4
icon_template: mdi:weather-sunny icon_template: mdi:weather-sunny
value_template: >- value_template: >-
{% from 'formatting.jinja' import cleanup %}
{%- macro getReport() -%} {%- macro getReport() -%}
{{ [ {{ [
'Tomorrow in Defiance ', 'Tomorrow in Defiance ',
@ -442,23 +433,13 @@ sensor:
] | random }} ] | random }}
{{ state_attr('sensor.tomorrow_forecast','overnight_low') }} degrees. {{ state_attr('sensor.tomorrow_forecast','overnight_low') }} degrees.
{%- endmacro -%} {%- endmacro -%}
{# a macro that removes all newline characters, empty spaces, and returns formatted text #} {{- cleanup(getReport()) -}}
{%- 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()) -}}
current_conditions: current_conditions:
friendly_name: Current Conditions friendly_name: Current Conditions
unique_id: 70db7e57-08db-48b2-919b-03b5face37b9 unique_id: 70db7e57-08db-48b2-919b-03b5face37b9
icon_template: mdi:weather-sunny icon_template: mdi:weather-sunny
value_template: >- value_template: >-
{% from 'formatting.jinja' import cleanup %}
{%- macro getReport() -%} {%- macro getReport() -%}
The Weather in Defiance The Weather in Defiance
{{ [ {{ [
@ -498,23 +479,13 @@ sensor:
and {{ states.weather.iron_nerd_weather_station.state }} and {{ states.weather.iron_nerd_weather_station.state }}
{% endif %} {% endif %}
{%- endmacro -%} {%- endmacro -%}
{# a macro that removes all newline characters, empty spaces, and returns formatted text #} {{- cleanup(getReport()) -}}
{%- 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()) -}}
current_conditions_detail: current_conditions_detail:
friendly_name: Current Conditions Detail friendly_name: Current Conditions Detail
unique_id: 2b3687d1-bdd5-4551-8c0a-05b1ff617543 unique_id: 2b3687d1-bdd5-4551-8c0a-05b1ff617543
icon_template: mdi:weather-sunny icon_template: mdi:weather-sunny
value_template: >- value_template: >-
{% from 'formatting.jinja' import cleanup %}
{%- macro getReport() -%} {%- macro getReport() -%}
The Weather in Defiance The Weather in Defiance
{{ [ {{ [
@ -660,18 +631,7 @@ sensor:
{{ states('sensor.overnight_lowest_temperature') }} degrees. {{ states('sensor.overnight_lowest_temperature') }} degrees.
{% endif %} {% endif %}
{%- endmacro -%} {%- endmacro -%}
{# a macro that removes all newline characters, empty spaces, and returns formatted text #} {{- cleanup(getReport()) -}}
{%- 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()) -}}
outside_pressure: outside_pressure:
friendly_name: 'Outside Pressure' friendly_name: 'Outside Pressure'
unique_id: ac2944bb-e9d7-40a3-9707-ef477fd5f309 unique_id: ac2944bb-e9d7-40a3-9707-ef477fd5f309
@ -725,6 +685,7 @@ sensor:
friendly_name: "Clothing Forecast Detail" friendly_name: "Clothing Forecast Detail"
unique_id: 13065f50-5eef-4afd-830e-2a2c87f47496 unique_id: 13065f50-5eef-4afd-830e-2a2c87f47496
value_template: >- value_template: >-
{% from 'formatting.jinja' import cleanup %}
{%- macro getReport() -%} {%- macro getReport() -%}
{% if is_state('binary_sensor.morning','on') %} {% if is_state('binary_sensor.morning','on') %}
Based on the forecasted high temperature, Based on the forecasted high temperature,
@ -874,19 +835,7 @@ sensor:
"The possibility of frost exists currently. Be prepared. " "The possibility of frost exists currently. Be prepared. "
{% endif %} {% endif %}
{%- endmacro -%} {%- endmacro -%}
{# a macro that removes all newline characters, empty spaces, and returns formatted text #} {{- cleanup(getReport()) -}}
{%- 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()) -}}
# current_inside_humidity: # current_inside_humidity:
# friendly_name: "Current Inside Humidity" # friendly_name: "Current Inside Humidity"
@ -905,6 +854,7 @@ sensor:
friendly_name: Weather Alert String friendly_name: Weather Alert String
unique_id: 66b5f020-0b5e-48ed-92a2-740d2d708b30 unique_id: 66b5f020-0b5e-48ed-92a2-740d2d708b30
value_template: > value_template: >
{% from 'formatting.jinja' import cleanup %}
{%- macro getReport() -%} {%- macro getReport() -%}
{% set alerts = [ {% set alerts = [
states('sensor.weatheralerts_alert_1_most_recent_active_alert'), states('sensor.weatheralerts_alert_1_most_recent_active_alert'),
@ -925,14 +875,7 @@ sensor:
'None' 'None'
{% endif %} {% endif %}
{%- endmacro -%} {%- endmacro -%}
{%- macro cleanup(data) -%} {{- cleanup(getReport()) -}}
{%- for item in data.split("\n") if item | trim != "" -%}
{{ item | trim }} {% endfor -%}
{%- endmacro -%}
{%- macro mother_of_all_macros() -%}
{{ getReport() }}
{%- endmacro -%}
{{- cleanup(mother_of_all_macros()) -}}
attribute_templates: attribute_templates:
active_alerts: "{{ states('sensor.weatheralerts_active_alerts') }}" active_alerts: "{{ states('sensor.weatheralerts_active_alerts') }}"
icon_template: > icon_template: >
@ -945,6 +888,7 @@ sensor:
friendly_name: 'Weather Alerts Active - Corrected' friendly_name: 'Weather Alerts Active - Corrected'
unique_id: e2f51da4-2271-4719-8edf-a28f76ac1e3f unique_id: e2f51da4-2271-4719-8edf-a28f76ac1e3f
value_template: > value_template: >
{% from 'formatting.jinja' import cleanup %}
{%- macro getReport() -%} {%- macro getReport() -%}
{% set alerts = [ {% set alerts = [
states('sensor.weatheralerts_alert_1_most_recent_active_alert'), states('sensor.weatheralerts_alert_1_most_recent_active_alert'),
@ -958,14 +902,7 @@ sensor:
{% set flood1 = 1 if (flood > 0) else 0 %} {% set flood1 = 1 if (flood > 0) else 0 %}
{{ (main + flood1) | int }} {{ (main + flood1) | int }}
{%- endmacro -%} {%- endmacro -%}
{%- macro cleanup(data) -%} {{- cleanup(getReport()) -}}
{%- for item in data.split("\n") if item | trim != "" -%}
{{ item | trim }} {% endfor -%}
{%- endmacro -%}
{%- macro mother_of_all_macros() -%}
{{ getReport() }}
{%- endmacro -%}
{{- cleanup(mother_of_all_macros()) -}}
icon_template: > icon_template: >
{% if (states('sensor.weatheralerts_active_alerts') | int ) > 0 %} {% if (states('sensor.weatheralerts_active_alerts') | int ) > 0 %}
mdi:alert mdi:alert

View File

@ -1489,6 +1489,7 @@ script:
data: data:
who: '{{ who }}' who: '{{ who }}'
message: >- message: >-
{% from 'formatting.jinja' import cleanup %}
{% macro greeting() %} {% macro greeting() %}
<p> <p>
{% if now().strftime('%H')|int < 12%} {% if now().strftime('%H')|int < 12%}
@ -1783,14 +1784,6 @@ script:
] | random }} ] | random }}
{% endmacro %} {% endmacro %}
{# a macro that removes all newline characters, empty spaces, and returns formatted text. Also replaces all 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 ******** #}
{# ********************************************* #} {# ********************************************* #}

View File

@ -177,6 +177,7 @@ sensor:
mdi:calendar-end mdi:calendar-end
{% endif %} {% endif %}
value_template: > value_template: >
{% from 'formatting.jinja' import cleanup %}
{%- macro getReport() -%} {%- macro getReport() -%}
{% set week = states('sensor.kallen_lunch_menu_week') %} {% set week = states('sensor.kallen_lunch_menu_week') %}
{% set dow = now().strftime('%A') %} {% set dow = now().strftime('%A') %}
@ -232,17 +233,7 @@ sensor:
No menu for the current day. No menu for the current day.
{% endif %} {% endif %}
{%- endmacro -%} {%- endmacro -%}
{# a macro that removes all newline characters, empty spaces, and returns formatted text #} {{- cleanup(getReport()) -}}
{%- 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()) -}}
# - platform: rest # - platform: rest

View File

@ -1,6 +1,7 @@
> >
{# Birthdays #} {# Birthdays #}
{%- macro getReport() -%} {%- macro getReport() -%}
{% from 'formatting.jinja' import cleanup %}
<p> <p>
{{ [ {{ [
'Attention household, I am told that there is a birthday among us!', 'Attention household, I am told that there is a birthday among us!',
@ -27,17 +28,4 @@
</p> </p>
{%- endmacro -%} {%- endmacro -%}
{{- cleanup(getReport()) -}}
{# 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()) -}}

View File

@ -1,6 +1,7 @@
> >
{# Daily Briefing #} {# Daily Briefing #}
{%- macro getReport() -%} {%- macro getReport() -%}
{% from 'formatting.jinja' import cleanup %}
{% from 'speech.jinja' import greeting, dadjoke, inspirational_quote %} {% from 'speech.jinja' import greeting, dadjoke, inspirational_quote %}
{% from 'status.jinja' import houseStatusReport, tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %} {% from 'status.jinja' import houseStatusReport, tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %}
{% from 'easy_time.jinja' import count_the_days %} {% from 'easy_time.jinja' import count_the_days %}
@ -312,18 +313,4 @@
</p> </p>
{%- endmacro -%} {%- endmacro -%}
{{- cleanup(getReport()) -}}
{# 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()) -}}

View File

@ -1,6 +1,7 @@
> >
{# Kallen Morning Briefing #} {# Kallen Morning Briefing #}
{%- macro getReport() -%} {%- macro getReport() -%}
{% from 'formatting.jinja' import cleanup %}
{% from 'time.jinja' import current_time, current_date_readout, input_datetime_read %} {% from 'time.jinja' import current_time, current_date_readout, input_datetime_read %}
{% from 'speech.jinja' import dadjoke, inspirational_quote %} {% from 'speech.jinja' import dadjoke, inspirational_quote %}
{% from 'easy_time.jinja' import count_the_days, custom_time %} {% from 'easy_time.jinja' import count_the_days, custom_time %}
@ -191,17 +192,4 @@
</p> </p>
{%- endmacro -%} {%- endmacro -%}
{{- cleanup(getReport()) -}}
{# 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()) -}}

View File

@ -1,6 +1,7 @@
> >
{# Kallen Nightly Briefing #} {# Kallen Nightly Briefing #}
{%- macro getReport() -%} {%- macro getReport() -%}
{% from 'formatting.jinja' import cleanup %}
{% from 'speech.jinja' import dadjoke %} {% from 'speech.jinja' import dadjoke %}
{% from 'easy_time.jinja' import count_the_days, custom_time %} {% from 'easy_time.jinja' import count_the_days, custom_time %}
<p> <p>
@ -116,18 +117,4 @@
</p> </p>
{%- endmacro -%} {%- endmacro -%}
{{- cleanup(getReport()) -}}
{# 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()) -}}

View File

@ -1,6 +1,7 @@
> >
{# Kallen School Status #} {# Kallen School Status #}
{%- macro getReport() -%} {%- macro getReport() -%}
{% from 'formatting.jinja' import cleanup %}
{% from 'time.jinja' import input_datetime_read %} {% from 'time.jinja' import input_datetime_read %}
<p> <p>
"Hello Collin, " "Hello Collin, "
@ -27,17 +28,4 @@
</p> </p>
{%- endmacro -%} {%- endmacro -%}
{{- cleanup(getReport()) -}}
{# 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()) -}}

View File

@ -1,6 +1,7 @@
> >
{# Morning Briefing #} {# Morning Briefing #}
{%- macro getReport() -%} {%- macro getReport() -%}
{% from 'formatting.jinja' import cleanup %}
{% from 'speech.jinja' import greeting_nodate, dadjoke, inspirational_quote %} {% from 'speech.jinja' import greeting_nodate, dadjoke, inspirational_quote %}
{% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %} {% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %}
{% from 'easy_time.jinja' import count_the_days %} {% from 'easy_time.jinja' import count_the_days %}
@ -187,18 +188,4 @@
</p> </p>
{%- endmacro -%} {%- endmacro -%}
{{- cleanup(getReport()) -}}
{# 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()) -}}

View File

@ -1,6 +1,7 @@
> >
{# Nightly Briefing #} {# Nightly Briefing #}
{%- macro getReport() -%} {%- macro getReport() -%}
{% from 'formatting.jinja' import cleanup %}
{% from 'speech.jinja' import greeting, dadjoke, inspirational_quote %} {% from 'speech.jinja' import greeting, dadjoke, inspirational_quote %}
{% from 'time.jinja' import input_datetime_read, time_from_calendar, next_twitch_stream %} {% from 'time.jinja' import input_datetime_read, time_from_calendar, next_twitch_stream %}
{% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %} {% from 'status.jinja' import tonyStatusReport, tinaStatusReport, kallenStatusReport, emmaStatusReport %}
@ -230,17 +231,4 @@
</p> </p>
{%- endmacro -%} {%- endmacro -%}
{{- cleanup(getReport()) -}}
{# 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()) -}}

View File

@ -1,6 +1,7 @@
> >
{# Weather Briefing #} {# Weather Briefing #}
{%- macro getReport() -%} {%- macro getReport() -%}
{% from 'formatting.jinja' import cleanup %}
<p> <p>
{% if is_state('input_boolean.tornado_alarm','on') %} {% if is_state('input_boolean.tornado_alarm','on') %}
@ -52,18 +53,4 @@
</p> </p>
{%- endmacro -%} {%- endmacro -%}
{{- cleanup(getReport()) -}}
{# 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()) -}}

View File

@ -1,6 +1,7 @@
> >
{# Welcome Home #} {# Welcome Home #}
{%- macro getReport() -%} {%- macro getReport() -%}
{% from 'formatting.jinja' import cleanup %}
{% from 'speech.jinja' import dadjoke %} {% from 'speech.jinja' import dadjoke %}
{% from 'time.jinja' import input_datetime_read %} {% from 'time.jinja' import input_datetime_read %}
{% from 'status.jinja' import emma_sleep %} {% from 'status.jinja' import emma_sleep %}
@ -174,17 +175,4 @@
</p> </p>
{%- endmacro -%} {%- endmacro -%}
{{- cleanup(getReport()) -}}
{# 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()) -}}