If you’d like to know when the temperature will be min/max (which hour of the day) and the value, here are four sensors that will get that. This assumes you have the forecast in a sensor called “weather.home_hourly” and that that sensors has an entry for each forecast with attributes ‘temperature’ and ‘datetime’. (I use met.no locally.)
- sensor:
- name: "Min Forecast Temperature in Next Day"
unique_id: min_forecast_temperature_in_next_day
state: >
{{ state_attr('weather.home_hourly','forecast')[:] | map(attribute='temperature')|min }}
attributes:
state_class: measurement
device_class: temperature
unit_of_measurement: °C
icon: mdi:thermometer
- sensor:
- name: "Min Forecast Temperature Hour in Next Day"
unique_id: min_forecast_temperature_hour_in_next_day
state: >
{% set min_temp = state_attr('weather.home_hourly','forecast')[:] | map(attribute='temperature')|min %}
{% set min_index = (state_attr('weather.home_hourly','forecast')[:] | map(attribute='temperature')|list).index(min_temp) %}
{% set coldest_hour = as_timestamp(state_attr('weather.home_hourly','forecast')[min_index]['datetime']) | timestamp_custom("%H") %}
{{coldest_hour}}
attributes:
icon: mdi:hours-24
- sensor:
- name: "Max Forecast Temperature in Next Day"
unique_id: max_forecast_temperature_in_next_day
state: >
{{ state_attr('weather.home_hourly','forecast')[:] | map(attribute='temperature')|max }}
attributes:
state_class: measurement
device_class: temperature
unit_of_measurement: °C
icon: mdi:thermometer
- sensor:
- name: "Max Forecast Temperature Hour in Next Day"
unique_id: max_forecast_temperature_hour_in_next_day
state: >
{% set max_temp = state_attr('weather.home_hourly','forecast')[:] | map(attribute='temperature')|max %}
{% set max_index = (state_attr('weather.home_hourly','forecast')[:] | map(attribute='temperature')|list).index(max_temp) %}
{% set warmest_hour = as_timestamp(state_attr('weather.home_hourly','forecast')[max_index]['datetime']) | timestamp_custom("%H") %}
{{warmest_hour}}
attributes:
icon: mdi:hours-24
Thank you. Just used max temperature part.
Just a small addition met.no entity weather.home_hourly reports forecast for next ~24 hours. So tehcnically it’s not a “Next day”
I use the following automation to send me a daily message about the weather:-
alias: Todays Temperature
description: ""
trigger:
- platform: time
at: "07:30:00"
condition: []
action:
- device_id: a47f7db07a4a9c7633ac807ab9d13457
domain: mobile_app
type: notify
title: Daily Forecast
message: >
Good Morning! The temperature outside is currently
{{state_attr('weather.forecast_home_hourly','temperature')}} degrees,
{%set highof = state_attr('weather.forecast_home_hourly','forecast')
| selectattr('datetime', 'search', now().timestamp() |
timestamp_custom('%Y-%m-%d')) | map(attribute='temperature') | max %} {%
if highof is defined and highof %} with a high of {{highof}} degrees
{%endif%} {%set lowof =
state_attr('weather.forecast_home_hourly','forecast') |
selectattr('datetime', 'search', now().timestamp() |
timestamp_custom('%Y-%m-%d')) | map(attribute='temperature') | min %} {%
if lowof is defined and lowof %} and a low of {{lowof}}{%endif%}. The
weather is forecast to be {{states('weather.forecast_home_hourly')}}{% set
currently_raining = states('weather.forecast_home_hourly') == 'rainy'
%}{%set check_for_rain =
state_attr('weather.forecast_home_hourly','forecast') |
selectattr('datetime', 'search', now().timestamp() |
timestamp_custom('%Y-%m-%d')) | selectattr('condition','equalto','rainy')
| list%}{%if not currently_raining%}{% if check_for_rain is defined and
check_for_rain %} and rainy. {% else %}, with no rain. {%endif%} {%else%}.
{%endif%} The house is currently
{{state_attr('climate.main_house','current_temperature')}} degrees.
mode: single
I used this code and it worked very much as intended. It seems to have stopped working since 2024.03 HASS Core update. I tried to update the code to the new entities but failed so far. Has anyone worked on this too?
He’s my original code above, now changed to use the new forecast service calls:-
alias: Todays Temperature
description: ""
trigger:
- platform: time
at: "07:30:00"
- platform: homeassistant
event: start
condition: []
action:
- service: weather.get_forecasts
target:
entity_id: weather.forecast_home
data:
type: hourly
response_variable: forecast_data
- service: notify.mobile_app__PUT_YOUR_PHONE_HERE
data:
title: Daily Forecast
message: >-
Good Morning! The temperature outside is currently {{
forecast_data['weather.forecast_home'].forecast[0].temperature }}
degrees, {%set highof = forecast_data['weather.forecast_home'].forecast
| selectattr('datetime', 'search', now().timestamp() |
timestamp_custom('%Y-%m-%d')) | map(attribute='temperature') | max %} {%
if highof is defined and highof %} with a high of {{highof}} degrees
{%endif%} {%set lowof = forecast_data['weather.forecast_home'].forecast
| selectattr('datetime', 'search', now().timestamp() |
timestamp_custom('%Y-%m-%d')) | map(attribute='temperature') | min %} {%
if lowof is defined and lowof %} and a low of {{lowof}}{%endif%}. The
weather is currently
{{forecast_data['weather.forecast_home'].forecast[0].condition}}{% set
currently_raining =
forecast_data['weather.forecast_home'].forecast[0].condition == 'rainy'
%}{%set check_for_rain = forecast_data['weather.forecast_home'].forecast
| selectattr('datetime', 'search', now().timestamp() |
timestamp_custom('%Y-%m-%d')) |
selectattr('condition','equalto','rainy') | list%}{%if not
currently_raining%}{% if check_for_rain is defined and check_for_rain %}
with rain forecast. {% else %}, with no rain forecast. {%endif%}
{%else%}. {%endif%} The house is currently
{{state_attr('climate.main_house','current_temperature')}} degrees.
mode: single