New weather forecast template

Alright jumping in on this thread now that 2024.4 is out and the forecast attribute has been removed. I updated a templated weather provider for my use case:

  • Start with a weather entity from the OpenWeather integration
  • Create a template weather entity combining a local sensor with the forecast from OpenWeather
  • Display this new entity in the weather-forecast card

I sorted it out after finding the very helpful debugging thread from @dbs: Debugging templates and service response_variables

template:
  - trigger:
      - platform: time_pattern
        hours: "/4"
      - platform: homeassistant
        event: start
      - platform: event
        event_type: event_template_reloaded
    action:
      - service: weather.get_forecasts
        data:
          type: daily
        target:
          entity_id: weather.daily
        response_variable: daily
    weather:
      name: Local
      temperature_template: "{{ states('sensor.outside_temp') | float(0) }}"
      temperature_unit: "°F"
      humidity_template: "{{ states('sensor.outside_humidity') | float(0) }}"
      condition_template: "{{ states('weather.daily') }}"
      forecast_daily_template: "{{ daily['weather.daily'].forecast }}"

A bit more involved than the previous 8 line template but it works :slight_smile:

Also FWIW, the docs still show the forecast_template option that was removed.

7 Likes