Template sensor weather forecast not working since core update

Hello all, i need your help :slight_smile:

Since last core update update my sensors for meteo seems to be broken:
Here is the error i have:
Enregistreur: homeassistant.helpers.template
Source: helpers/template.py:2558
S’est produit pour la première fois: 09:39:16 (56 occurrences)
Dernier enregistrement: 09:54:46

* Template variable error: None has no element 4 when rendering '{{ state_attr('weather.maison', 'forecast')[4].condition }}'
* Template variable error: None has no element 4 when rendering '{{ state_attr('weather.maison', 'forecast')[4].temperature }}'
* Template variable error: None has no element 5 when rendering '{{ state_attr('weather.maison', 'forecast')[5].condition }}'
* Template variable error: None has no element 5 when rendering '{{ state_attr('weather.maison', 'forecast')[5].temperature }}'
- platform: template
  sensors: 
    # Capteur pour la condition météo actuelle
    weather_condition_now:
      friendly_name: "Condition Météo Actuelle"
      value_template: >
        {% set cond_now = states('weather.maison') %}
        {% if states('sun.sun') == 'below_horizon' %}
            {% if cond_now == 'sunny' %} night {% elif cond_now == 'partlycloudy' %} night-partly-cloudy {% else %} {{ cond_now }} {% endif %}
        {% else %}
            {{ cond_now }}
        {% endif %}

    # Capteurs pour les conditions météo futures
    # Condition Météo Future 0
    weather_condition_future_0:
      friendly_name: "Condition Météo Future 0"
      value_template: "{{ state_attr('weather.maison', 'forecast')[0].condition }}"

    weather_temperature_future_0:
      friendly_name: "Température Météo Future 0"
      value_template: "{{ state_attr('weather.maison', 'forecast')[0].temperature }}"
      unit_of_measurement: '°C'

    # Condition Météo Future 1
    weather_condition_future_1:
      friendly_name: "Condition Météo Future 1"
      value_template: "{{ state_attr('weather.maison', 'forecast')[1].condition }}"

    weather_temperature_future_1:
      friendly_name: "Température Météo Future 1"
      value_template: "{{ state_attr('weather.maison', 'forecast')[1].temperature }}"
      unit_of_measurement: '°C'

    # Condition Météo Future 2
    weather_condition_future_2:
      friendly_name: "Condition Météo Future 2"
      value_template: "{{ state_attr('weather.maison', 'forecast')[2].condition }}"

    weather_temperature_future_2:
      friendly_name: "Température Météo Future 2"
      value_template: "{{ state_attr('weather.maison', 'forecast')[2].temperature }}"
      unit_of_measurement: '°C'

    # Condition Météo Future 3
    weather_condition_future_3:
      friendly_name: "Condition Météo Future 3"
      value_template: "{{ state_attr('weather.maison', 'forecast')[3].condition }}"

    weather_temperature_future_3:
      friendly_name: "Température Météo Future 3"
      value_template: "{{ state_attr('weather.maison', 'forecast')[3].temperature }}"
      unit_of_measurement: '°C'
      
    # Condition Météo Future 4
    weather_condition_future_4:
      friendly_name: "Condition Météo Future 4"
      value_template: "{{ state_attr('weather.maison', 'forecast')[4].condition }}"

    weather_temperature_future_4:
      friendly_name: "Température Météo Future 4"
      value_template: "{{ state_attr('weather.maison', 'forecast')[4].temperature }}"
      unit_of_measurement: '°C'
      
    # Condition Météo Future 5
    weather_condition_future_5:
      friendly_name: "Condition Météo Future 5"
      value_template: "{{ state_attr('weather.maison', 'forecast')[5].condition }}"

    weather_temperature_future_5:
      friendly_name: "Température Météo Future 5"
      value_template: "{{ state_attr('weather.maison', 'forecast')[5].temperature }}"
      unit_of_measurement: '°C'

Met.no integration working ans showing forecasts



  • Core2024.4.1
  • Supervisor2024.03.1
  • Operating System12.1
  • Interface utilisateur20240404.1

It’s been deprecated in favour of a service calls many months ago (6, I think). It was removed in this version. The change is noted in the release notes and blog post.

Do a search: There are a number of posts a put this and there’s an example in the weather docs.

1 Like

i don’t saw that, how to solve it?

What did you search for and where?

There’s an example, literally in the weather docs.

Just Google: “home assistant weather forecast attribute removed”.

1 Like

Someone else recently asked a similar question and I explained what they needed to do here:

1 Like