L1p0
(Lipovics Martin)
April 14, 2021, 12:36pm
1
HI!
I’m trying to get the maximum and minimum temperature value of today from the Met.no 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)}}
{%endif%}
{% 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!
Thanks!
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']}}
L1p0
(Lipovics Martin)
April 14, 2021, 12:50pm
3
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
123
(Taras)
April 14, 2021, 1:48pm
5
(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 }}
Screenshot:
Confirmation that the correct Min and Max values were selected for today (Wednesday):
5 Likes