Help with Templating to get the max and min value

I’m trying to get the maximum and minimum temperature value of today from the integration hourly entity!

{%for i in range(0,24)%}
	{%if as_timestamp(state_attr("weather.home_hourly", "forecast")[i].datetime) | timestamp_custom('%Y-%m-%d') == as_timestamp(now()) | timestamp_custom('%Y-%m-%d')%}
		{{state_attr("weather.home_hourly", "forecast")[i].temperature | round(0)}} 
{% endfor %}

with this i get all the temperature values that i need. But i would like the get out from this values the max and min value! Anyone can help me pls?
Sorry for my bad English!

The template you are looing for might be these

For high temperature of the tomorrow.

{{ state_attr('weather.home_hourly', 'forecast')[0]['temperature']}}

For the lowest temperature of tomorrow

{{ state_attr('weather.home_hourly', 'forecast')[0]['templow']}}

yeah, I forgot to write that i need the temps of today. But thanks anyway!

This was just to point you in the direction. I hope that you can build your template form this.
If you need help do ask.

1 Like

(Original proposal has been revised.)

Copy-paste this into the Template Editor and confirm it works for you:

{% set tomorrow = (as_timestamp(now().date() + timedelta(days=1)) | timestamp_utc)
  .replace(' ', 'T') ~ '+00:00' %}
{% set today = state_attr('weather.home_hourly', 'forecast')
  | selectattr('datetime', 'lt', tomorrow) | map(attribute='temperature') | list %}

Max: {{ today | max }}, Min: {{ today | min }}


Confirmation that the correct Min and Max values were selected for today (Wednesday):
Screenshot from 2021-04-14 09-53-26


Thank You, thats works! :grinning:

1 Like