Need help with forecast template

Hi community,

I have been trying to get some forecast sensors from the new get_forecasts services, but I am somehow doing something wrong as my sensors just don’t show up in HA.

template:

  - trigger:
    - platform: time_pattern
      hours: "/1"
    - platform: homeassistant
      event: start
    action:
      - service: weather.get_forecasts
        target:
          entity_id: weather.my_home
        data:
          type: daily
        response_variable: daily
    sensor:
      - name: Open Meteo Today Forecast
        unique_id: open_meteo_today_forecast
        state: "{{ daily['weather.my_home'].forecast[0] }}"
      - name: Open Meteo Today Min Temperature
        unique_id: open_meteo_today_min_temperature
        state: "{{ daily['weather.my_home'].forecast[0].templow }}"
        unit_of_measurement: °C
        device_class: temperature
      - name: Open Meteo Today Max Temperature
        unique_id: open_meteo_today_max_temperature
        state: "{{ daily['weather.my_home'].forecast[0].temperature }}"
        unit_of_measurement: °C
        device_class: temperature

Does someone see what I am missing?
Thanks!

Probably because there is no forecast attribute for “weather.my_home”

At a guess, the entire first forecast object in the first sensor is larger that the state limit of 255 characters.

That’s why, in the examples people have posted in various threads, the forecast is usually set up as an attribute, as they don’t have that limit.

There is,

Calling the service in dev tools,

service: weather.get_forecast
target:
  entity_id: weather.my_home
data:
  type: daily

provides this response:

forecast:
  - datetime: "2024-04-27"
    condition: rainy
    wind_bearing: 142
    temperature: 16
    templow: 7.1
    wind_speed: 15
    precipitation: 5
  - datetime: "2024-04-28"
    condition: rainy
    wind_bearing: 200
    temperature: 14.6
    templow: 8.4
    wind_speed: 27.3
    precipitation: 1.3
  - datetime: "2024-04-29"
    condition: rainy
    wind_bearing: 178
    temperature: 18
    templow: 7.3
    wind_speed: 16.2
    precipitation: 0
  - datetime: "2024-04-30"
    condition: rainy
    wind_bearing: 136
    temperature: 19.5
    templow: 10.3
    wind_speed: 15
    precipitation: 1.5
  - datetime: "2024-05-01"
    condition: rainy
    wind_bearing: 196
    temperature: 21.3
    templow: 13.5
    wind_speed: 10.1
    precipitation: 5.5
  - datetime: "2024-05-02"
    condition: rainy
    wind_bearing: 261
    temperature: 14.7
    templow: 9.7
    wind_speed: 18.9
    precipitation: 11.6
  - datetime: "2024-05-03"
    condition: rainy
    wind_bearing: 328
    temperature: 15.3
    templow: 8
    wind_speed: 19.8
    precipitation: 1.5

Check the attributes under states in dev tools

There isn’t (anymore), it’s just the conversion to the new forecast service that I am trying to set up.

With this change, the forecast attribute of the weather entity is deprecated, and will be removed in Home Assistant Core 2024.3.

Exactly, the only new sensor you will have with your config is “weather.my_home”

I am ashamed, my code was fine, but there was another trigger template further down the yaml deactivating my first one.
Sorry :frowning:

1 Like