For reference: this is what I have in my sensors.yaml file:
# Day min and max temp
- platform: template
sensors:
day_max_temp:
friendly_name: "Tagshöchsttemperatur"
unit_of_measurement: "°C"
entity_id: weather.openweathermap
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 }}
day_min_temp:
friendly_name: "Tagstiefsttemperatur"
unit_of_measurement: "°C"
entity_id: weather.openweathermap
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 }}