Can't access forecast attribute with weather cards

Hello everyone,
since 2024.4 I cannot use weather cards anymore and I am kind of at a loss.

I get forecast temperatures with forecast_home but they don’t have precipitation or precipitation probability.

Trying different other cards, I just don’t get any forecasts. When checking with the dev tool I see, that my entity has them.


This seems like everything is fine. However, using cards that show more details looks like this: it just refuses to show me the hourly forecasts even though the options are toggled:



Flipping the toggle in the hourly card just adds an empty line.

Everything tries to use the same weather entity.

Does anyone know what this is?

The forecast attribute was marked as deprecated since 2023.9
From 2024.4, you have to use the get_forecasts service.
You need to call a service or create a custom sensor like I did (thanks to adorobis)

# Old weather style
  - trigger:
    - platform: time_pattern
      hours: /1
    - platform: homeassistant
      event: start
    action:
      - service: weather.get_forecasts
        data:
          type: daily
        target:
          entity_id: weather.openweathermap
        response_variable: daily
    sensor:
      - name: Old forecast style weather
        state: "{{ states('weather.openweathermap') }}"
        attributes:
          temperature: "{{ state_attr('weather.openweathermap', 'temperature') }}"
          dew_point: "{{ state_attr('weather.openweathermap', 'dew_point') }}"
          temperature_unit: "{{ state_attr('weather.openweathermap', 'temperature_unit') }}"
          humidity: "{{ state_attr('weather.openweathermap', 'humidity') }}"
          cloud_coverage: "{{ state_attr('weather.openweathermap', 'cloud_coverage') }}"
          pressure: "{{ state_attr('weather.openweathermap', 'pressure') }}"
          pressure_unit: "{{ state_attr('weather.openweathermap', 'pressure_unit') }}"
          wind_bearing: "{{ state_attr('weather.openweathermap', 'wind_bearing') }}"
          wind_speed: "{{ state_attr('weather.openweathermap', 'wind_speed') }}"
          wind_speed_unit: "{{ state_attr('weather.openweathermap', 'wind_speed_unit') }}"
          visibility_unit: "{{ state_attr('weather.openweathermap', 'visibility_unit') }}"
          precipitation_unit: "{{ state_attr('weather.openweathermap', 'precipitation_unit') }}"
          forecast: "{{ daily['weather.openweathermap'].forecast }}"

And get from this

To this

1 Like

I have seen this solution quite a bit on the forums here. However, according to my understanding you are creating a sensor entity: sensor.old_…

However, the weather cards requite a weather entity: weather.old_… They won’t see the sensor.entity.

Can I somehow do that as well with a template like that?

It is working fine for me …


OpenWeather is only providing daily forecast but I’m ok with that.

I’m using it in a custom card

type: custom:weather-chart-card
entity: sensor.old_forecast_style_weather

image

1 Like

I was relying on the drop down menu… The menu only showed me weather entities. I never came up with the idea to force the card to use another type of entity via yaml. WOW that’s annoying.

Thanks for your help. I wouldn’t have gotten to this point and realizing my mistake without seeing your first screenshot with the yaml section.

What is the top level field in this? Is it an automation? The sensor entry causes that to fail. And neither of the following will pass YAML parse checks:

- platform: weather
# Old weather style
  - trigger:
    - platform: time_pattern
      hours: /1
    - platform: homeassistant
      event: start
....

- platform: template
# Old weather style
  - trigger:
    - platform: time_pattern
      hours: /1
    - platform: homeassistant
      event: start
....

It should be a template. I had the problem that I wanted an hourly sensor and I didn’t replace all the ‘daily’ with hourly.
Which led to mine not being accepted.

That doesn’t seem to work, either. I load my sensors thru yaml includes via sensor: !include_dir_merge_list includes/sensors.

Using this block:

- platform: template
# Old weather style
  trigger:
    - platform: time_pattern
      hours: /1
    - platform: homeassistant
      event: start
  action:
      - service: weather.get_forecasts
        data:
          type: daily
        target:
          entity_id: weather.openweathermap
        response_variable: daily
  sensor:
      - name: Old forecast style weather
        state: "{{ states('weather.openweathermap') }}"
        attributes:
          temperature: "{{ state_attr('weather.openweathermap', 'temperature') }}"
          dew_point: "{{ state_attr('weather.openweathermap', 'dew_point') }}"
          temperature_unit: "{{ state_attr('weather.openweathermap', 'temperature_unit') }}"
          humidity: "{{ state_attr('weather.openweathermap', 'humidity') }}"
          cloud_coverage: "{{ state_attr('weather.openweathermap', 'cloud_coverage') }}"
          pressure: "{{ state_attr('weather.openweathermap', 'pressure') }}"
          pressure_unit: "{{ state_attr('weather.openweathermap', 'pressure_unit') }}"
          wind_bearing: "{{ state_attr('weather.openweathermap', 'wind_bearing') }}"
          wind_speed: "{{ state_attr('weather.openweathermap', 'wind_speed') }}"
          wind_speed_unit: "{{ state_attr('weather.openweathermap', 'wind_speed_unit') }}"
          visibility_unit: "{{ state_attr('weather.openweathermap', 'visibility_unit') }}"
          precipitation_unit: "{{ state_attr('weather.openweathermap', 'precipitation_unit') }}"
          forecast: "{{ daily['weather.openweathermap'].forecast }}"

The YAML check complains:

Invalid config for 'template' from integration 'sensor' at includes/sensors/weather.yaml, line 257: required key 'sensors' not provided
Invalid config for 'template' from integration 'sensor' at includes/sensors/weather.yaml, line 264: 'action' is an invalid option for 'sensor.template', check: action
Invalid config for 'template' from integration 'sensor' at includes/sensors/weather.yaml, line 271: 'sensor' is an invalid option for 'sensor.template', check: sensor

Changing sensor to sensors gives different validation errors:

Invalid config for 'template' from integration 'sensor' at includes/sensors/weather.yaml, line 264: 'action' is an invalid option for 'sensor.template', check: action
Invalid config for 'template' from integration 'sensor' at includes/sensors/weather.yaml, line 271: expected dictionary for dictionary value 'sensors', got [{'name': 'Old forecast style weather', 'state': "{{ states('weather.openweathermap') }}", 'attributes': {'temperature': "{{ state_attr('weather.openweathermap', 'temperature') }}", 'dew_point': "{{ state_attr('weather.openweathermap', 'dew_point') }}", 'temperature_unit': "{{ state_attr('weather.openweathermap', 'temperature_unit') }}", 'humidity': "{{ state_attr('weather.openweathermap', 'humidity') }}", 'cloud_coverage': "{{ state_attr('weather.openweathermap', 'cloud_coverage') }}", 'pres
...

Given none of the recommendations given here work (see this post), I’ve had to make the action sequence include publishing the payload and THEN creating a new MQTT sensor to parse the payload. What a hack.

I’m not sure who planned this functionality, but it’s pretty short sighted to make things not be backwards compatible on a whim. I mean… do they think that no one has automations based on things like tomorrow’s expected high or precipitation?

Maybe it’s just me…

grumpyoldman

1 Like

Solving the issue: it’s not a sensor template, it’s a template integration. One needs have/add to their configuration.yaml:

template: !include templates.yaml