Get Daily Max/Min Temperature from Weather

As the Attributes of the DWD Weather Integration have been updated my Template Sensor fetching todays highest temperature stopped working.

- trigger:
    - trigger: time
      at: "00:00:01"
    - trigger: homeassistant
      event: start
    - trigger: event
      event_type: event_template_reloaded
  action:
    - action: weather.get_forecasts
      data:
        type: daily
      target:
        entity_id: weather.home
      response_variable: weather_data
  sensor:
    - name: "Max temp"
      unique_id: max_daily_temp
      state: >-
        {{ weather_data.forecast[0].temperature }}
      unit_of_measurement: "°C"
    - name: "Min temp"
      unique_id: min_daily_temp
      state: >-
        {{ weather_data.forecast[0].templow }}
      unit_of_measurement: "°C"

Whilst this is the output of weather.get_forecasts:

weather.home:
  forecast:
    - datetime: "2024-12-21T00:00:00Z"
      cloud_coverage: 100
      condition: cloudy
      evaporation: null
      fog_probability: 4
      precipitation_duration: 7860
      precipitation_probability: 68
      pressure: 1025.4
      sun_duration: 6300
      sun_irradiance: 2430
      uv_index: null
      visibility: 7900
      wind_gust_speed: 35.2
      wind_bearing: SW
      temperature: 5
      templow: -2
      dew_point: 1
      wind_speed: 20.4
      precipitation: 0.3
    - datetime: "2024-12-22T00:00:00Z" [...]

Can anyone help me in how I am fetching the results wrongly?

Is the discrepency expected?
Otherwise, I don’t see anything wrong

Yes, that was me trying to hide location information when sharing the config and obviously failed in doing so :see_no_evil:

This is the error log I’m getting:

  • Error rendering state template for sensor.max_temp: UndefinedError: ‘dict object’ has no attribute ‘forecast’
  • Error rendering state template for sensor.min_temp: UndefinedError: ‘dict object’ has no attribute ‘forecast’

I guess you need {{ weather_data["weather.home"].forecast[0].temperature }}

1 Like