This commit is contained in:
Edward Firmo
2023-12-18 15:40:13 +01:00
parent 83c641deef
commit 75c9246c5e

View File

@@ -9064,7 +9064,9 @@ action:
continue_on_error: true
- variables:
forecast: >
{% if use_new_forecasts and service_response_var is defined and service_response_var[weather_entity] is defined and service_response_var[weather_entity].forecast is defined %}
{% if use_new_forecasts and service_response_var is defined
and service_response_var[weather_entity] is defined
and service_response_var[weather_entity].forecast is defined %}
{{ service_response_var[weather_entity].forecast }}
{% elif service_response_var is defined and service_response_var.forecast is defined %}
{{ service_response_var.forecast }}
@@ -9166,7 +9168,7 @@ action:
]
{% endif %}
- if: '{{ forecast_day | count > 0 or page_index == 0 }}'
then: # Display forecast
then: # Display forecast
- variables:
metnoweather: '{{ weather_type == "Met.no" }}'
metnoweather_hourly_forecast: '{{ state_attr(weather_entity ~ "_hourly", "forecast") if metnoweather and has_value(weather_entity ~ "_hourly") }}'
@@ -9200,39 +9202,97 @@ action:
accuweather_sensor_prefix: '{{ "sensor." ~ (weather_entity | replace("weather.","")) ~ "_" }}'
accuweather_sensor_sufix: '{{ "_" ~ page_index ~ "d" }}'
temp_min: >
{{ forecast_day | selectattr("templow", "defined") | map(attribute="templow") | map("float") | list | min
{{
forecast_day | selectattr("templow", "defined") | map(attribute="templow") | map("float") | list | min
if forecast_day | selectattr("templow", "defined") | map(attribute="templow") | map("float") | list | count > 0
else forecast_day | selectattr("temperature", "defined") | rejectattr("temperature", "eq", "") | map(attribute="temperature") | map("float") | list | min | default("unknown")
else
forecast_day
| selectattr("temperature", "defined")
| rejectattr("temperature", "eq", "")
| map(attribute="temperature")
| map("float") | list | min | default("unknown")
}}
temp_max: >
{{
forecast_day | selectattr("temperature", "defined") | rejectattr("temperature", "eq", "") | map(attribute="temperature") | map("float") | list | max
if forecast_day | selectattr("temperature", "defined") | rejectattr("temperature", "eq", "") | map(attribute="temperature") | map("float") | list | count > 0
forecast_day
| selectattr("temperature", "defined")
| rejectattr("temperature", "eq", "")
| map(attribute="temperature")
| map("float") | list | max
if
forecast_day
| selectattr("temperature", "defined")
| rejectattr("temperature", "eq", "")
| map(attribute="temperature")
| map("float") | list | count > 0
}}
condition: >
{{
forecast_day | selectattr("condition", "defined") | rejectattr("condition", "eq", "") | map(attribute="condition") | list | first
if forecast_day | selectattr("condition", "defined") | rejectattr("condition", "eq", "") | map(attribute="condition") | list | count > 0
forecast_day
| selectattr("condition", "defined")
| rejectattr("condition", "eq", "")
| map(attribute="condition") | list | first
if
forecast_day
| selectattr("condition", "defined")
| rejectattr("condition", "eq", "")
| map(attribute="condition") | list | count > 0
}}
precipitation: >
{{
forecast_day | selectattr("precipitation", "defined") | rejectattr("precipitation", "eq", "") | map(attribute="precipitation") | map("float") | list | sum | round(0)
if forecast_day | selectattr("precipitation", "defined") | rejectattr("precipitation", "eq", "") | map(attribute="precipitation") | map("float") | list | count > 0
forecast_day
| selectattr("precipitation", "defined")
| rejectattr("precipitation", "eq", "")
| map(attribute="precipitation")
| map("float") | list | sum | round(0)
if
forecast_day
| selectattr("precipitation", "defined")
| rejectattr("precipitation", "eq", "")
| map(attribute="precipitation")
| map("float") | list | count > 0
}}
precipitation_probability: >
{{
forecast_day | selectattr("precipitation_probability", "defined") | rejectattr("precipitation_probability", "eq", "") | map(attribute="precipitation_probability") | map("float") | list | max | round(0)
if forecast_day | selectattr("precipitation_probability", "defined") | rejectattr("precipitation_probability", "eq", "") | map(attribute="precipitation_probability") | map("float") | list | count > 0
forecast_day
| selectattr("precipitation_probability", "defined")
| rejectattr("precipitation_probability", "eq", "")
| map(attribute="precipitation_probability")
| map("float") | list | max | round(0)
if
forecast_day
| selectattr("precipitation_probability", "defined")
| rejectattr("precipitation_probability", "eq", "")
| map(attribute="precipitation_probability")
| map("float") | list | count > 0
}}
pressure: >
{{
forecast_day | selectattr("pressure", "defined") | rejectattr("pressure", "eq", "") | map(attribute="pressure") | map("float") | list | max | round(0)
if forecast_day | selectattr("pressure", "defined") | rejectattr("pressure", "eq", "") | map(attribute="pressure") | map("float") | list | count > 0
forecast_day
| selectattr("pressure", "defined")
| rejectattr("pressure", "eq", "")
| map(attribute="pressure")
| map("float") | list | max | round(0)
if
forecast_day
| selectattr("pressure", "defined")
| rejectattr("pressure", "eq", "")
| map(attribute="pressure")
| map("float") | list | count > 0
}}
wind_speed: >
{{
forecast_day | selectattr("wind_speed", "defined") | rejectattr("wind_speed", "eq", "") | map(attribute="wind_speed") | map("float") | list | max | round(0)
if forecast_day | selectattr("wind_speed", "defined") | rejectattr("wind_speed", "eq", "") | map(attribute="wind_speed") | map("float") | list | count > 0
forecast_day
| selectattr("wind_speed", "defined")
| rejectattr("wind_speed", "eq", "")
| map(attribute="wind_speed")
| map("float") | list | max | round(0)
if
forecast_day
| selectattr("wind_speed", "defined")
| rejectattr("wind_speed", "eq", "")
| map(attribute="wind_speed")
| map("float") | list | count > 0
}}
hours_of_sun: >
{{
@@ -9240,8 +9300,22 @@ action:
if accuweather
else
(
forecast_day | selectattr("hours_of_sun", "defined") | rejectattr("hours_of_sun", "eq", "") | map(attribute="hours_of_sun") | map("float") | list | sum | round(0)
if forecast_day | selectattr("hours_of_sun", "defined") | rejectattr("hours_of_sun", "eq", "") | map(attribute="hours_of_sun") | map("float") | list | count > 0
forecast_day
| selectattr("hours_of_sun", "defined")
| rejectattr("hours_of_sun", "eq", "")
| map(attribute="hours_of_sun")
| map("float")
| list
| sum
| round(0)
if
forecast_day
| selectattr("hours_of_sun", "defined")
| rejectattr("hours_of_sun", "eq", "")
| map(attribute="hours_of_sun")
| map("float")
| list
| count > 0
)
}}
uv_index: >
@@ -9250,8 +9324,22 @@ action:
if accuweather
else
(
forecast_day | selectattr("uv_index", "defined") | rejectattr("uv_index", "eq", "") | map(attribute="uv_index") | map("float") | list | max | round(0)
if forecast_day | selectattr("uv_index", "defined") | rejectattr("uv_index", "eq", "") | map(attribute="uv_index") | map("float") | list | count > 0
forecast_day
| selectattr("uv_index", "defined")
| rejectattr("uv_index", "eq", "")
| map(attribute="uv_index")
| map("float")
| list
| max
| round(0)
if
forecast_day
| selectattr("uv_index", "defined")
| rejectattr("uv_index", "eq", "")
| map(attribute="uv_index")
| map("float")
| list
| count > 0
)
}}
thunderstorm_probability: >
@@ -9260,14 +9348,41 @@ action:
if accuweather
else
(
forecast_day | selectattr("thunderstorm_probability", "defined") | rejectattr("thunderstorm_probability", "eq", "") | map(attribute="thunderstorm_probability") | map("float") | list | max | round(0)
if forecast_day | selectattr("thunderstorm_probability", "defined") | rejectattr("thunderstorm_probability", "eq", "") | map(attribute="thunderstorm_probability") | map("float") | list | count > 0
forecast_day
| selectattr("thunderstorm_probability", "defined")
| rejectattr("thunderstorm_probability", "eq", "")
| map(attribute="thunderstorm_probability") | map("float")
| list
| max
| round(0)
if
forecast_day
| selectattr("thunderstorm_probability", "defined")
| rejectattr("thunderstorm_probability", "eq", "")
| map(attribute="thunderstorm_probability")
| map("float")
| list
| count > 0
)
}}
humidity: >
{{
forecast_day | selectattr("humidity", "defined") | rejectattr("humidity", "eq", "") | map(attribute="humidity") | map("float") | list | max | round(0)
if forecast_day | selectattr("humidity", "defined") | rejectattr("humidity", "eq", "") | map(attribute="humidity") | map("float") | list | count > 0
forecast_day
| selectattr("humidity", "defined")
| rejectattr("humidity", "eq", "")
| map(attribute="humidity")
| map("float")
| list
| max
| round(0)
if
forecast_day
| selectattr("humidity", "defined")
| rejectattr("humidity", "eq", "")
| map(attribute="humidity")
| map("float")
| list
| count > 0
}}
parameters:
- name: hours_of_sun