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