My current forecast & tomorrow forecast templates for the integrations Accuweather and Meteorologisk institutt (Met.no) don't work anymore. Both show unavailable

Hello all,

I noticed that my current forecast & tomorrow forecast templates for the integrations Accuweather and Meteorologisk institutt (Met.no) don’t work anymore. Both show unavailable.

  - platform: template
    sensors:

# Meteorologisk institutt
      meteoswiss_weather_temphigh_today:
        friendly_name: "Clotilde Weather Forecast Temperature High Today"
        value_template: "{{ state_attr('weather.forecast_home', 'forecast')[0]['temperature'] }}"
      meteoswiss_weather_templow_today:
        friendly_name: "Clotilde Weather Forecast Temperature Low Today"
        value_template: "{{ state_attr('weather.forecast_home', 'forecast')[0]['templow'] }}"        
              
# Accuweather     
      accu_weather_temphigh_tomorrow:
        friendly_name: "Accu Weather Forecast Temperature High Tomorrow"
        value_template: "{{ state_attr('weather.geneva', 'forecast')[1]['temperature'] }}"
      accu_weather_templow_tomorrow:
        friendly_name: "Accu Weather Forecast Temperature Low Tomorrow"
        value_template: "{{ state_attr('weather.geneva', 'forecast')[1]['templow'] }}"
      accu_weather_temphigh_today:
        friendly_name: "Accu Weather Forecast Temperature High Today"
        value_template: "{{ state_attr('weather.geneva', 'forecast')[0]['temperature'] }}"
      accu_weather_templow_today:
        friendly_name: "Accu Weather Forecast Temperature Low Today"
        value_template: "{{ state_attr('weather.geneva', 'forecast')[0]['templow'] }}"

I read through a few post here like:
https://community.home-assistant.io/t/can-someone-here-help-me-understand-how-to-fix-my-current-forecast-and-tomorrow-forecast-template-weather-sensor-both-show-unavailable/654724

https://community.home-assistant.io/t/how-to-migrate-from-weather-integration-approach-to-new-weather-get-forecast-service/619481/2

I somehow understand that something changed in HA but to me its not clear what I actually need to change in my configuration.yaml.

The details are there in HA: Temp high is 18.5 and temp low is 7.5
I checked also this in Developer tools / Template

{{ state_attr('weather.forecast_home', 'forecast')[0]['temperature'] }}

but it gives me an error: UndefinedError: None has no element 0

I’m not really good in coding. Grateful if someone can point me to the right direction?

There was a change in 2024.4

Thanks Mark

I read though Backward-incompatible changes / Weather / post where it says:

The previously deprecated forecast attribute of weather entities, has now been removed. Use the weather.get_forecasts service to get the forecast data instead.

So had a look at the “Example template sensor that contains the hourly forecast”, went to Settings > Devices & Services > Helpers. and created a template binary

template:
  - trigger:
      - platform: time_pattern
        hours: /1
    action:
      - service: weather.get_forecasts
        data:
          type: hourly
        target:
          entity_id: weather.openweathermap
        response_variable: hourly
    sensor:
      - name: Temperature forecast next hour
        unique_id: temperature_forecast_next_hour
        state: "{{ hourly['weather.openweathermap'].forecast[0].temperature }}"
        unit_of_measurement: °C

but that doesn’t work, error message:
“This template does not listen for any events and will not update automatically.”
Again, I’m not good in coding, any idea what I’m doing wrong.
Additionally, what would be the code to be entered into the configuration.yaml ?

  1. You said you created a Template Binary Sensor helper but the example you posted is a Trigger-based Template Binary Sensor. Currently, there are only two kinds of Template helpers: sensor and binary_sensor (the Trigger-based variant isn’t supported).

  2. Did you put all of that YAML code into the State Template field? Because if you did, it would cause the error message you received. That field is meant to contain a Jinja2 template and nothing else.

1 Like

Thanks Taras

You’re absolutely correct, yes I did put it into the State Template field.
I’m not fully into HA, sometimes it could help if HA would tell these “stupids” where exactly a code has to be entered. Anyway…
So where should I enter it or how do I amend my existing configuration.yaml entry to make it work again. Besides, Accuweather doesn’t support hourly updates, only daily one.

# Accuweather
  - platform: template
    sensors:     
      accu_weather_temphigh_tomorrow:
        friendly_name: "Accu Weather Forecast Temperature High Tomorrow"
        value_template: "{{ state_attr('weather.geneva', 'forecast')[1]['temperature'] }}"
      accu_weather_templow_tomorrow:
        friendly_name: "Accu Weather Forecast Temperature Low Tomorrow"
        value_template: "{{ state_attr('weather.geneva', 'forecast')[1]['templow'] }}"
      accu_weather_temphigh_today:
        friendly_name: "Accu Weather Forecast Temperature High Today"
        value_template: "{{ state_attr('weather.geneva', 'forecast')[0]['temperature'] }}"
      accu_weather_templow_today:
        friendly_name: "Accu Weather Forecast Temperature Low Today"
        value_template: "{{ state_attr('weather.geneva', 'forecast')[0]['templow'] }}"

Thanks, Heiner

1 Like

I can confirm this works now

configuration.yaml

# Accuweather
template:
  - trigger:
      - platform: time_pattern
        hours: /1
    action:
      - service: weather.get_forecasts
        data:
          type: daily
        target:
          entity_id: weather.geneva
        response_variable: daily
    sensor:
      - name: Accuweather Temperature Max Today (user added)  
        unique_id: accuweather_temperature_max_today_new
        state: "{{ daily['weather.geneva'].forecast[0].temperature }}"
        unit_of_measurement: °C
        
      - name: Accuweather Temperature Low Today (user added)
        unique_id: accuweather_temperature_low_today_new
        state: "{{ daily['weather.geneva'].forecast[0].templow }}"
        unit_of_measurement: °C
      
      - name: AccuWeather Temperature Max Tomorrow (user added)
        unique_id: accuweather_max_tomorrow_new
        state: "{{ daily['weather.geneva'].forecast[1].temperature }}"
        unit_of_measurement: °C
        
      - name: Accuweather Temperature Low Tomorrow (user added)
        unique_id: accuweather_low_tomorrow_new
        state: "{{ daily['weather.geneva'].forecast[1].templow }}"
        unit_of_measurement: °C
        
      - name: AccuWeather Condition Tomorrow (user added)
        unique_id: accuweather_condition_tomorrow_new
        state: "{{ daily['weather.geneva'].forecast[1].condition }}"    

# Meteorologisk / MeteoSwiss  
  - trigger:
      - platform: time_pattern
        hours: /1
    action:
      - service: weather.get_forecasts
        data:
          type: daily
        target:
          entity_id: weather.forecast_home
        response_variable: daily
    sensor:
      - name: MeteoSwiss Temperature Max Today (user added)
        unique_id: meteoswiss_temperature_max_today_new
        state: "{{ daily['weather.forecast_home'].forecast[0].temperature }}"
        unit_of_measurement: °C        

      - name: MeteoSwiss Temperature Low Today (user added)
        unique_id: meteoswiss_temperature_low_today_new
        state: "{{ daily['weather.forecast_home'].forecast[0].templow }}"
        unit_of_measurement: °C
        
      - name: MeteoSwiss Temperature Max Tomorrow (user added)
        unique_id: meteoswiss_temperature_max_tomorrow_new
        state: "{{ daily['weather.forecast_home'].forecast[1].temperature }}"
        unit_of_measurement: °C        

      - name: MeteoSwiss Temperature Low Tomorrow (user added)
        unique_id: meteoswiss_temperature_low_tomorrow_new
        state: "{{ daily['weather.forecast_home'].forecast[1].templow }}"
        unit_of_measurement: °C
        
      - name: MeteoSwiss Condition Tomorrow (user added)
        unique_id: meteoswiss_weather_condition_tomorrow_new
        state: "{{ daily['weather.forecast_home'].forecast[1].condition }}"

I have seen other solution like here New weather forecast template or Debugging templates and service response_variables

1 Like

Thanks for sharing

Anyone coming here for accuweather does not need to make templates. The integration outputs all the information OP is asking for. They are separate sensors, check the list of disabled sensors in the accuweather entities integration list.

3 Likes

And for Tomorrow.IO users?

Maybe, I don’t use tomorrow.io, but you can simply check your list of disabled entities for the integration.

Have done, no disabled entities with any values.

In the template evaluator I ran the following to list all attributes,

{% for k,v in states.weather.tomorrow_io_cabin_daily.attributes.items() -%}
{{ k }}: {{ v }}
{% endfor %}

Yep the forecast attribute is definitely gone.

But the strange thing is, when I click the above entity in the integration, I can see the forecast weather data (e.g it’s going to rain tomorrow).

But I can’t figure out where/how to access that data. i.e Obviously HA has it somewhere, but it is no longer an attribute of that entity, and there are no other Tomorow.IO entities that contain that information.

I have searched for all (including disabled/hidden) entities of Tomorrow.io, and all entities containing the name “forecast” etc, I cant find the forecast data anywhere.

Any more suggestions?

Yes, it was removed from all weather entities.

it’s accessed in a service call. It’s covered in weather docs and even covered in the post you replied to with

Thanks for sharing

Thanks, ya got it, used [This](https://community.home-assistant.io/t/forecast-depreciation/713543/2)

Yes its a super unclear new changed, for people who are not super intimate with HA. (And I’m fairly intimate, share a few blueprints etc).

I think what is missing from the docs/explanations (for me anyhow) is just a clearer explanation of the work flow.
Also, it really doesn’t help that the docs dont show an example of how to get all the forecast data. (Sure, that would be obvious to a HA Dev, but it’s clearly not an obvious jump for many)

I would put it like this:

  • Your weather Entity used to have a “forecast” Attribute, which is how you used to get your forecast data. You perhaps accessed your daily forcast something like this: {{state_attr('weather.myweatherservice', 'Forecast')[0] }}
  • The forecast Attribute has now been removed. So, what we are going to do is create a new Sensor that contains the forecast data, and then query that new Sensor, instead of querying the Weather Service.
    *First: we need to create a new “Template Sensor”, which is triggered every hour, that will query the Weather Service and populate our Sensor for us.

*Now, you can get your daily forecast again, by querying the new sensor, instead of querying the weather integration, like this:
state_attr('sensor.my_weather_forecast', 'forecast')[0])

(Obviously the last line etc will change a bit depending on the Template example). But for sure this is far from the smoothest “change” home assistant has had - the documents could be a lot better and describing the transition process IMHO. Lots of people are struggling with this one, for a reason.

You’re welcome to suggest changes for documentation.

1 Like

When they have a sizeable full time paid team, these kind of snark responses don’t look good. If they want to build a real smart home brand as the recent announcements claim, they have to make clear instructions for people and not snarkily reply to people that they should do it themselves.

Home assistant is still largely done by volunteers, like myself. You will always get snark from me when you complain instead of just simply asking for help.

FYI the dev who changed this was a volunteer too :wink: