Retrieve highest forecasted temperature from a weather entity

I used to be able to retrieve the max forecasted temperature for the current day in an automation by accessing {{ state_attr('weather.openweathermap_2', 'forecast') | map(attribute='temperature') | max }}. But when I try accessing the max forecasted temperature, I am unable to retrieve a value. When opening the weather sensor in the entities view, I am able to view the max forecasted temperature, so this issue should not be related to missing sensor data.

If anyone knows what the right way is to retrieve this data, please help :slight_smile:

The forecast attribute in weather entities has been removed some time ago.
You need to access the data through a service now: Weather - Home Assistant

With the removal of the forecast attribute it does make this a bit harder, but the solution is to use the get_forecasts method to populate a sensor that has a forecast attribute and then you are back to where you were before.

trigger:
  - platform: time_pattern
    minutes: /5
  - platform: homeassistant
    event: start

action:
  - service: weather.get_forecasts
    data:
      type: daily
    target:
      entity_id: weather.openweathermap
    response_variable: owm_daily
sensor:
  - name: Legacy Forecasts
    state: "{{ states('weather.openweathermap') }}"

    attributes:
      forecast: "{{ owm_daily['weather.openweathermap'].forecast }}"

Firstly, thank you both for your help. I think I need some more help. Do I have to create an automation with this configuration:
trigger:

  • platform: time_pattern
    minutes: /5
  • platform: homeassistant
    event: start

action:

  • service: weather.get_forecasts
    data:
    type: daily
    target:
    entity_id: weather.openweathermap
    response_variable: owm_daily
    sensor:

  • name: Legacy Forecasts
    state: “{{ states(‘weather.openweathermap’) }}”

    attributes:
    forecast: “{{ owm_daily[‘weather.openweathermap’].forecast }}”

or do I have to save it in the configuration.yaml? Thanks in advance! :wink:

Hi, welcome to the forum.
You need to create a template.

A little search on the forum reveals the answers Search results for 'forecast weather template' - Home Assistant Community

Neither.
You just need to call the service in the specific automation you use. Creating a separate template sensor and automation defeats the initial purpose why the get_forecasts service was introduced: to only retrieve the data when it is actually needed.

Thanks a lot, I was now able to get my weather forecast up and running :grinning: