Hi, I tried to get the max/min Results of some OpenWeatherMap-Forecasts like above described.
I want to know the max/min Temperature in the next 24 hours and the max Windspeed/Cloud Coverage/Rain also in the next 24h.
I used this code:
# Maximale und minimale Temperaturwerte aus Openweathermap
- platform: template
sensors:
min_temp_next_24h:
friendly_name: Minimale Temperatur in den naechsten 24h
value_template: >-
{% set start = (now().replace(hour=0,minute=0,second=0).timestamp() * 1000) | int %}
{% set end = start + 86400000 %}
{{ state_attr('weather.openweathermap', 'forecast') | selectattr('datetime', '>', start) | selectattr('datetime','<=', end) | map(attribute='temperature') | list | min }}
max_temp_next_24h:
friendly_name: Maximale Temperatur in den naechsten 24h
value_template: >-
{% set start = (now().replace(hour=0,minute=0,second=0).timestamp() * 1000) | int %}
{% set end = start + 86400000 %}
{{ state_attr('weather.openweathermap', 'forecast') | selectattr('datetime', '>', start) | selectattr('datetime','<=', end) | map(attribute='temperature') | list | max }}
max_windspeed_next_24h:
friendly_name: Maximale Windgeschwindigkeit in den naechsten 24h
value_template: >-
{% set start = (now().replace(hour=0,minute=0,second=0).timestamp() * 1000) | int %}
{% set end = start + 86400000 %}
{{ state_attr('weather.openweathermap', 'forecast') | selectattr('datetime', '>', start) | selectattr('datetime','<=', end) | map(attribute='wind_speed') | list | max }}
max_cloudcoverage_next_24h:
friendly_name: Maximale Bewoelkung in den naechsten 24h
value_template: >-
{% set start = (now().replace(hour=0,minute=0,second=0).timestamp() * 1000) | int %}
{% set end = start + 86400000 %}
{{ state_attr('weather.openweathermap', 'forecast') | selectattr('datetime', '>', start) | selectattr('datetime','<=', end) | map(attribute='cloud_coverage') | list | max }}
max_raining_next_24h:
friendly_name: Maximale Regenmenge in den naechsten 24h
value_template: >-
{% set start = (now().replace(hour=0,minute=0,second=0).timestamp() * 1000) | int %}
{% set end = start + 86400000 %}
{{ state_attr('weather.openweathermap', 'forecast') | selectattr('datetime', '>', start) | selectattr('datetime','<=', end) | map(attribute='rain') | list | max }}
But there must be an error in the code.
There is just a result for min and max temperature.
And the other sensors just show “unknown”. Maybe the name of the attribute is wrong. But i can’t find the right name.
Can someone help with the code?