How to migrate from weather integration approach to new weather.get_forecast service?

The service call’s name is now plural:

weather.get_forecasts

The new service call lets you get the forecast from multiple weather entities. The response_variable’s structure is slightly different so you have to specify which entity’s forecast you want (even if you only asked for the forecast from one weather entity).

daily['weather.my_weather'].forecast

Example

template:
# My Weather Entities Daily
  - trigger:
      - platform: state
        entity_id: weather.my_weather
    action:
      - service: weather.get_forecasts
        data:
          type: daily
        target:
          entity_id: weather.my_weather
        response_variable: daily
    sensor:
      - name: My Weather Forecast Daily
        icon: mdi:weather-cloudy
        state: "{{ daily['weather.my_weather'].forecast[0].condition }}"
        attributes:
          forecast: "{{ daily['weather.my_weather'].forecast }}"
5 Likes