Fix formatting in custom weather package templates

This commit is contained in:
2025-08-16 18:20:28 -04:00
parent 9678ccd2a3
commit b97838a13f

View File

@@ -865,30 +865,30 @@ template:
icon: mdi:weather-sunny icon: mdi:weather-sunny
state: >- state: >-
{% from 'formatting.jinja' import cleanup %} {% from 'formatting.jinja' import cleanup %}
{%- macro getReport() -%} {% macro getReport() %}
{{ [ {{ [
'Today in Defiance ', 'Today in Defiance ',
'Later Today ', 'Later Today ',
'For the rest of the day ' 'For the rest of the day '
] | random }} ] | random }}
expect a high of {{ states('sensor.todays_high_temp') }} expect a high of {{ states('sensor.todays_high_temp') }}
{%- if states('sensor.current_forecast') == 'sunny' and is_state('binary_sensor.night','off')%} {% if states('sensor.current_forecast') == 'sunny' and is_state('binary_sensor.night','off')%}
{{ [ {{ [
'and sunny. ', 'and sunny. ',
'with sun. ', 'with sun. ',
'with sunny conditions prevailing. ' 'with sunny conditions prevailing. '
] | random }} ] | random }}
{%- elif states('sensor.current_forecast') == 'sunny' and is_state('binary_sensor.night','on') %} {% elif states('sensor.current_forecast') == 'sunny' and is_state('binary_sensor.night','on') %}
{{ [ {{ [
'and clear. ', 'and clear. ',
'with clear skies. ' 'with clear skies. '
] | random }} ] | random }}
{%- elif states('sensor.current_forecast') == 'clear-night' %} {% elif states('sensor.current_forecast') == 'clear-night' %}
{{ [ {{ [
'and clear. ', 'and clear. ',
'with clear skies. ' 'with clear skies. '
] | random }} ] | random }}
{%- elif states('sensor.current_forecast') == 'rainy' %} {% elif states('sensor.current_forecast') == 'rainy' %}
{{ [ {{ [
'with rain. ', 'with rain. ',
'with showers. ', 'with showers. ',
@@ -900,7 +900,7 @@ template:
] | random }} ] | random }}
near {{ state_attr('sensor.current_forecast','precipitation') }} inches near {{ state_attr('sensor.current_forecast','precipitation') }} inches
{{ 'possible. ' }} {{ 'possible. ' }}
{%- elif states('sensor.current_forecast') == 'snowy' %} {% elif states('sensor.current_forecast') == 'snowy' %}
{{ [ {{ [
'with snow. ', 'with snow. ',
'with snow showers. ' 'with snow showers. '
@@ -911,19 +911,19 @@ template:
] | random }} ] | random }}
near {{ state_attr('sensor.current_forecast','precipitation') }} inches near {{ state_attr('sensor.current_forecast','precipitation') }} inches
{{ 'possible. ' }} {{ 'possible. ' }}
{%- elif states('sensor.current_forecast') == 'snowy-rainy' %} {% elif states('sensor.current_forecast') == 'snowy-rainy' %}
{{ [ {{ [
'with mix preciptation possible. ', 'with mix preciptation possible. ',
'with snow and rain showers. ' 'with snow and rain showers. '
] | random }} ] | random }}
Total accumulation near {{ state_attr('sensor.current_forecast','precipitation') }} inches Total accumulation near {{ state_attr('sensor.current_forecast','precipitation') }} inches
{{ 'possible. ' }} {{ 'possible. ' }}
{%- elif states('sensor.current_forecast') == 'windy' %} {% elif states('sensor.current_forecast') == 'windy' %}
{{ [ {{ [
'and windy. ', 'and windy. ',
'with lots of wind. ' 'with lots of wind. '
] | random }} ] | random }}
{%- elif states('sensor.current_forecast') == 'fog' %} {% elif states('sensor.current_forecast') == 'fog' %}
{{ [ {{ [
'and foggy. ', 'and foggy. ',
'with some fog. ' 'with some fog. '
@@ -939,7 +939,7 @@ template:
'with partly cloudy skies. ', 'with partly cloudy skies. ',
'with scattered clouds ' 'with scattered clouds '
] | random }} ] | random }}
{%- elif states('sensor.current_forecast') == 'hail' %} {% elif states('sensor.current_forecast') == 'hail' %}
{{ [ {{ [
'with severe thunderstorms possible. ', 'with severe thunderstorms possible. ',
'with hail possible. ' 'with hail possible. '
@@ -950,7 +950,7 @@ template:
] | random }} ] | random }}
near {{ state_attr('sensor.current_forecast','precipitation') }} inches near {{ state_attr('sensor.current_forecast','precipitation') }} inches
{{ 'possible. ' }} {{ 'possible. ' }}
{%- elif states('sensor.current_forecast') == 'lightning' %} {% elif states('sensor.current_forecast') == 'lightning' %}
{{ [ {{ [
'with thunderstorms possible. ', 'with thunderstorms possible. ',
'with the potential of thunderstorms. ' 'with the potential of thunderstorms. '
@@ -961,14 +961,14 @@ template:
] | random }} ] | random }}
near {{ state_attr('sensor.current_forecast','precipitation') }} inches near {{ state_attr('sensor.current_forecast','precipitation') }} inches
{{ 'possible. ' }} {{ 'possible. ' }}
{% endif -%} {% endif %}
{{ [ {{ [
'Later tonight expect a low of ', 'Later tonight expect a low of ',
'Overnight expect a low of ' 'Overnight expect a low of '
] | random }} ] | random }}
{{ states('sensor.overnight_lowest_temperature') }} degrees. {{ states('sensor.overnight_lowest_temperature') }} degrees.
{%- endmacro -%} {% endmacro %}
{{- cleanup(getReport()) -}} {{ cleanup(getReport()) }}
- name: Tomorrows Forecast - name: Tomorrows Forecast
unique_id: a8ae26b0-ed26-4568-bb2b-f7c72707b009 unique_id: a8ae26b0-ed26-4568-bb2b-f7c72707b009
icon: mdi:weather-sunny icon: mdi:weather-sunny
@@ -996,20 +996,20 @@ template:
icon: mdi:weather-sunny icon: mdi:weather-sunny
state: >- state: >-
{% from 'formatting.jinja' import cleanup %} {% from 'formatting.jinja' import cleanup %}
{%- macro getReport() -%} {% macro getReport() %}
{{ [ {{ [
'Tomorrow in Defiance ', 'Tomorrow in Defiance ',
'For the next day ', 'For the next day ',
'Tomorrow ' 'Tomorrow '
] | random }} ] | random }}
expect a high of {{ state_attr('sensor.tomorrow_forecast','high_temp') }} degrees. expect a high of {{ state_attr('sensor.tomorrow_forecast','high_temp') }} degrees.
{%- if states('sensor.tomorrow_forecast') == 'sunny' %} {% if states('sensor.tomorrow_forecast') == 'sunny' %}
{{ [ {{ [
'and sunny. ', 'and sunny. ',
'with sun. ', 'with sun. ',
'with sunny conditions prevailing. ' 'with sunny conditions prevailing. '
] | random }} ] | random }}
{%- elif states('sensor.tomorrow_forecast') == 'rainy' %} {% elif states('sensor.tomorrow_forecast') == 'rainy' %}
{{ [ {{ [
'with rain. ', 'with rain. ',
'with showers. ', 'with showers. ',
@@ -1021,7 +1021,7 @@ template:
] | random }} ] | random }}
near {{ state_attr('sensor.tomorrow_forecast','precipitation') }} inches near {{ state_attr('sensor.tomorrow_forecast','precipitation') }} inches
{{ 'possible. ' }} {{ 'possible. ' }}
{%- elif states('sensor.tomorrow_forecast') == 'snowy' %} {% elif states('sensor.tomorrow_forecast') == 'snowy' %}
{{ [ {{ [
'with snow. ', 'with snow. ',
'with snow showers. ' 'with snow showers. '
@@ -1032,19 +1032,19 @@ template:
] | random }} ] | random }}
near {{ state_attr('sensor.tomorrow_forecast','precipitation') }} inches near {{ state_attr('sensor.tomorrow_forecast','precipitation') }} inches
{{ 'possible. ' }} {{ 'possible. ' }}
{%- elif states('sensor.tomorrow_forecast') == 'snowy-rainy' %} {% elif states('sensor.tomorrow_forecast') == 'snowy-rainy' %}
{{ [ {{ [
'with mix preciptation possible. ', 'with mix preciptation possible. ',
'with snow and rain showers. ' 'with snow and rain showers. '
] | random }} ] | random }}
Total accumulation near {{ state_attr('sensor.tomorrow_forecast','precipitation') }} inches Total accumulation near {{ state_attr('sensor.tomorrow_forecast','precipitation') }} inches
{{ 'possible. ' }} {{ 'possible. ' }}
{%- elif states('sensor.tomorrow_forecast') == 'windy' %} {% elif states('sensor.tomorrow_forecast') == 'windy' %}
{{ [ {{ [
'and windy. ', 'and windy. ',
'with lots of wind. ' 'with lots of wind. '
] | random }} ] | random }}
{%- elif states('sensor.current_forecast') == 'fog' %} {% elif states('sensor.current_forecast') == 'fog' %}
{{ [ {{ [
'and foggy. ', 'and foggy. ',
'with some fog. ' 'with some fog. '
@@ -1060,7 +1060,7 @@ template:
'with partly cloudy skies. ', 'with partly cloudy skies. ',
'with scattered clouds ' 'with scattered clouds '
] | random }} ] | random }}
{%- elif states('sensor.tomorrow_forecast') == 'hail' %} {% elif states('sensor.tomorrow_forecast') == 'hail' %}
{{ [ {{ [
'with severe thunderstorms possible. ', 'with severe thunderstorms possible. ',
'with hail possible. ' 'with hail possible. '
@@ -1071,7 +1071,7 @@ template:
] | random }} ] | random }}
near {{ state_attr('sensor.current_forecast','precipitation') }} inches near {{ state_attr('sensor.current_forecast','precipitation') }} inches
{{ 'possible. ' }} {{ 'possible. ' }}
{%- elif states('sensor.current_forecast') == 'lightning' %} {% elif states('sensor.current_forecast') == 'lightning' %}
{{ [ {{ [
'with thunderstorms possible. ', 'with thunderstorms possible. ',
'with the potential of thunderstorms. ' 'with the potential of thunderstorms. '
@@ -1082,19 +1082,19 @@ template:
] | random }} ] | random }}
near {{ state_attr('sensor.current_forecast','precipitation') }} inches near {{ state_attr('sensor.current_forecast','precipitation') }} inches
{{ 'possible. ' }} {{ 'possible. ' }}
{% endif -%} {% endif %}
{{ [ {{ [
' Tomorrow night expect a low of ' ' Tomorrow night expect a low of '
] | random }} ] | random }}
{{ state_attr('sensor.tomorrow_forecast','overnight_low') }} degrees. {{ state_attr('sensor.tomorrow_forecast','overnight_low') }} degrees.
{%- endmacro -%} {% endmacro %}
{{- cleanup(getReport()) -}} {{ cleanup(getReport()) }}
- name: Current Conditions - name: Current Conditions
unique_id: 70db7e57-08db-48b2-919b-03b5face37b9 unique_id: 70db7e57-08db-48b2-919b-03b5face37b9
icon: mdi:weather-sunny icon: mdi:weather-sunny
state: >- state: >-
{% from 'formatting.jinja' import cleanup %} {% from 'formatting.jinja' import cleanup %}
{%- macro getReport() -%} {% macro getReport() %}
The Weather in Defiance The Weather in Defiance
{{ [ {{ [
' is ', ' is ',
@@ -1132,14 +1132,14 @@ template:
{% else %} {% else %}
and {{ states.weather.iron_nerd_weather_station.state }} and {{ states.weather.iron_nerd_weather_station.state }}
{% endif %} {% endif %}
{%- endmacro -%} {% endmacro %}
{{- cleanup(getReport()) -}} {{ cleanup(getReport()) }}
- name: Current Conditions Detail - name: Current Conditions Detail
unique_id: 2b3687d1-bdd5-4551-8c0a-05b1ff617543 unique_id: 2b3687d1-bdd5-4551-8c0a-05b1ff617543
icon: mdi:weather-sunny icon: mdi:weather-sunny
state: >- state: >-
{% from 'formatting.jinja' import cleanup %} {% from 'formatting.jinja' import cleanup %}
{%- macro getReport() -%} {% macro getReport() %}
The Weather in Defiance The Weather in Defiance
{{ [ {{ [
' is ', ' is ',
@@ -1177,29 +1177,29 @@ template:
{% else %} {% else %}
and {{ states.weather.iron_nerd_weather_station.state }}. and {{ states.weather.iron_nerd_weather_station.state }}.
{% endif %} {% endif %}
{%- if is_state('binary_sensor.early_night_mode','off')%} {% if is_state('binary_sensor.early_night_mode','off')%}
{{ [ {{ [
'Later Today ', 'Later Today ',
'For the rest of the day ' 'For the rest of the day '
] | random }} ] | random }}
expect a high of {{ states('sensor.todays_high_temp') }} expect a high of {{ states('sensor.todays_high_temp') }}
{%- if states('sensor.current_forecast') == 'sunny' and is_state('binary_sensor.night','off')%} {% if states('sensor.current_forecast') == 'sunny' and is_state('binary_sensor.night','off')%}
{{ [ {{ [
'and sunny. ', 'and sunny. ',
'with sun. ', 'with sun. ',
'with sunny conditions prevailing. ' 'with sunny conditions prevailing. '
] | random }} ] | random }}
{%- elif states('sensor.current_forecast') == 'sunny' and is_state('binary_sensor.night','on') %} {% elif states('sensor.current_forecast') == 'sunny' and is_state('binary_sensor.night','on') %}
{{ [ {{ [
'and clear. ', 'and clear. ',
'with clear skies. ' 'with clear skies. '
] | random }} ] | random }}
{%- elif states('sensor.current_forecast') == 'clear-night' %} {% elif states('sensor.current_forecast') == 'clear-night' %}
{{ [ {{ [
'and clear. ', 'and clear. ',
'with clear skies. ' 'with clear skies. '
] | random }} ] | random }}
{%- elif states('sensor.current_forecast') == 'rainy' %} {% elif states('sensor.current_forecast') == 'rainy' %}
{{ [ {{ [
'with rain. ', 'with rain. ',
'with showers. ', 'with showers. ',
@@ -1210,7 +1210,7 @@ template:
'Total Rainfall amounts ' 'Total Rainfall amounts '
] | random }} ] | random }}
near {{ state_attr('sensor.current_forecast','precipitation') }} inches {{ 'possible. ' }} near {{ state_attr('sensor.current_forecast','precipitation') }} inches {{ 'possible. ' }}
{%- elif states('sensor.current_forecast') == 'snowy' %} {% elif states('sensor.current_forecast') == 'snowy' %}
{{ [ {{ [
'with snow. ', 'with snow. ',
'with snow showers. ' 'with snow showers. '
@@ -1221,18 +1221,18 @@ template:
] | random }} ] | random }}
near {{ state_attr('sensor.current_forecast','precipitation') }} inches near {{ state_attr('sensor.current_forecast','precipitation') }} inches
{{ 'possible. ' }} {{ 'possible. ' }}
{%- elif states('sensor.current_forecast') == 'snowy-rainy' %} {% elif states('sensor.current_forecast') == 'snowy-rainy' %}
{{ [ {{ [
'with mix preciptation possible. ', 'with mix preciptation possible. ',
'with snow and rain showers. ' 'with snow and rain showers. '
] | random }} ] | random }}
Total accumulation near {{ state_attr('sensor.current_forecast','precipitation') }} inches {{ 'possible. ' }} Total accumulation near {{ state_attr('sensor.current_forecast','precipitation') }} inches {{ 'possible. ' }}
{%- elif states('sensor.current_forecast') == 'windy' %} {% elif states('sensor.current_forecast') == 'windy' %}
{{ [ {{ [
'and windy. ', 'and windy. ',
'with lots of wind. ' 'with lots of wind. '
] | random }} ] | random }}
{%- elif states('sensor.current_forecast') == 'fog' %} {% elif states('sensor.current_forecast') == 'fog' %}
{{ [ {{ [
'and foggy. ', 'and foggy. ',
'with some fog. ' 'with some fog. '
@@ -1248,7 +1248,7 @@ template:
'with partly cloudy skies. ', 'with partly cloudy skies. ',
'with scattered clouds. ' 'with scattered clouds. '
] | random }} ] | random }}
{%- elif states('sensor.current_forecast') == 'hail' %} {% elif states('sensor.current_forecast') == 'hail' %}
{{ [ {{ [
'with severe thunderstorms possible. ', 'with severe thunderstorms possible. ',
'with hail possible. ' 'with hail possible. '
@@ -1259,7 +1259,7 @@ template:
] | random }} ] | random }}
near {{ state_attr('sensor.current_forecast','precipitation') }} inches near {{ state_attr('sensor.current_forecast','precipitation') }} inches
{{ 'possible. ' }} {{ 'possible. ' }}
{%- elif states('sensor.current_forecast') == 'lightning' %} {% elif states('sensor.current_forecast') == 'lightning' %}
{{ [ {{ [
'with thunderstorms possible. ', 'with thunderstorms possible. ',
'with the potential of thunderstorms. ' 'with the potential of thunderstorms. '
@@ -1270,21 +1270,21 @@ template:
] | random }} ] | random }}
near {{ state_attr('sensor.current_forecast','precipitation') }} inches near {{ state_attr('sensor.current_forecast','precipitation') }} inches
{{ 'possible. ' }} {{ 'possible. ' }}
{% endif -%} {% endif %}
{{ [ {{ [
'Later tonight expect a low of ', 'Later tonight expect a low of ',
'Overnight expect a low of ' 'Overnight expect a low of '
] | random }} ] | random }}
{{ states('sensor.overnight_lowest_temperature') }} degrees. {{ states('sensor.overnight_lowest_temperature') }} degrees.
{%- else -%} {% else %}
{{ [ {{ [
'Tonight expect a low of ', 'Tonight expect a low of ',
'Overnight expect a low of ' 'Overnight expect a low of '
] | random }} ] | random }}
{{ states('sensor.overnight_lowest_temperature') }} degrees. {{ states('sensor.overnight_lowest_temperature') }} degrees.
{% endif %} {% endif %}
{%- endmacro -%} {% endmacro %}
{{- cleanup(getReport()) -}} {{ cleanup(getReport()) }}
- name: 'Outside Pressure' - name: 'Outside Pressure'
unique_id: ac2944bb-e9d7-40a3-9707-ef477fd5f309 unique_id: ac2944bb-e9d7-40a3-9707-ef477fd5f309
state: '{{ state_attr(''weather.iron_nerd_weather_station'',''pressure'') }}' state: '{{ state_attr(''weather.iron_nerd_weather_station'',''pressure'') }}'
@@ -1517,7 +1517,7 @@ template:
unique_id: 66b5f020-0b5e-48ed-92a2-740d2d708b30 unique_id: 66b5f020-0b5e-48ed-92a2-740d2d708b30
state: > state: >
{% from 'formatting.jinja' import cleanup %} {% 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'),
states('sensor.weatheralerts_alert_2_most_recent_active_alert'), states('sensor.weatheralerts_alert_2_most_recent_active_alert'),
@@ -1536,8 +1536,8 @@ template:
{% else %} {% else %}
'None' 'None'
{% endif %} {% endif %}
{%- endmacro -%} {% endmacro %}
{{- cleanup(getReport()) -}} {{ cleanup(getReport()) }}
attributes: attributes:
active_alerts: "{{ states('sensor.weatheralerts_active_alerts') }}" active_alerts: "{{ states('sensor.weatheralerts_active_alerts') }}"
icon: > icon: >
@@ -1550,7 +1550,7 @@ template:
unique_id: e2f51da4-2271-4719-8edf-a28f76ac1e3f unique_id: e2f51da4-2271-4719-8edf-a28f76ac1e3f
state: > state: >
{% from 'formatting.jinja' import cleanup %} {% 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'),
states('sensor.weatheralerts_alert_2_most_recent_active_alert'), states('sensor.weatheralerts_alert_2_most_recent_active_alert'),
@@ -1562,8 +1562,8 @@ template:
{% set flood = alerts | reject ('eq','unavailable') | select('eq','Flood Warning') | list | count | int %} {% set flood = alerts | reject ('eq','unavailable') | select('eq','Flood Warning') | list | count | int %}
{% set flood1 = 1 if (flood > 0) else 0 %} {% set flood1 = 1 if (flood > 0) else 0 %}
{{ (main + flood1) | int }} {{ (main + flood1) | int }}
{%- endmacro -%} {% endmacro %}
{{- cleanup(getReport()) -}} {{ cleanup(getReport()) }}
icon: > icon: >
{% if (states('sensor.weatheralerts_active_alerts') | int ) > 0 %} {% if (states('sensor.weatheralerts_active_alerts') | int ) > 0 %}
mdi:alert mdi:alert