Yevgenium / weather-chart-card

Custom weather card with charts
MIT License
274 stars 80 forks source link

From 2024.4.0, attributes.forecast will be removed #141

Open OToussaint opened 3 months ago

OToussaint commented 3 months ago

Starting this 3rd of April 2024, the new release of HA is no longer publishing the forecast as an attribute. The code accessing attributes.forecastmust be replaced by a call the get_forecasts service:

Probably something like this.

  homeassistant.callService(weather, 'get_forecasts', {
    type: 'daily',
  }).then(function(response) {
    // Check that forecasts is in the answer
    if (!response || !response.forecasts) {
      console.error('No forecast data available');
      return;
    }

Otherwise the card will show

Please, check your weather entity

Unfortunately, as an old programmer, I'm not good enough in JS to change it myself in a fork.

Pabsilon commented 3 months ago

I just updated to 2024.4.0 and as OToussaint said, the card no longer works.

adorobis commented 3 months ago

You can create a template sensor to get the daily (and hourly) forecast. Here is my example for daily. It will create a new sensor which you can add to the card.

- trigger:
  - platform: time_pattern
    hours: /1
  - platform: homeassistant
    event: start
  action:
    - service: weather.get_forecasts
      data:
        type: daily
      target:
        entity_id: weather.forecast_gaszowice
      response_variable: daily
  sensor:
    - name: Forecast Gaszowice Daily
      state: "{{ states('weather.forecast_gaszowice') }}"
      attributes:
        temperature: "{{ state_attr('weather.forecast_gaszowice', 'temperature') }}"
        dew_point: "{{ state_attr('weather.forecast_gaszowice', 'dew_point') }}"
        temperature_unit: "{{ state_attr('weather.forecast_gaszowice', 'temperature_unit') }}"
        humidity: "{{ state_attr('weather.forecast_gaszowice', 'humidity') }}"
        cloud_coverage: "{{ state_attr('weather.forecast_gaszowice', 'cloud_coverage') }}"
        pressure: "{{ state_attr('weather.forecast_gaszowice', 'pressure') }}"
        pressure_unit: "{{ state_attr('weather.forecast_gaszowice', 'pressure_unit') }}"
        wind_bearing: "{{ state_attr('weather.forecast_gaszowice', 'wind_bearing') }}"
        wind_speed: "{{ state_attr('weather.forecast_gaszowice', 'wind_speed') }}"
        wind_speed_unit: "{{ state_attr('weather.forecast_gaszowice', 'wind_speed_unit') }}"
        visibility_unit: "{{ state_attr('weather.forecast_gaszowice', 'visibility_unit') }}"
        precipitation_unit: "{{ state_attr('weather.forecast_gaszowice', 'precipitation_unit') }}"
        forecast: "{{ daily['weather.forecast_gaszowice'].forecast }}"
CrashyNL commented 3 months ago

I just updated to 2024.4.0 and as OToussaint said, the card no longer works.

Same here

sekonicpr commented 3 months ago

Im having the same issue.

slecram commented 3 months ago

This hacs integegration works with 2024.4 forecasts https://github.com/mlamberts78/weather-chart-card

mbrevda commented 3 months ago

This hacs integegration works with 2024.4 forecasts https://github.com/mlamberts78/weather-chart-card

That doesn't seem to show hourly forcasts

slecram commented 3 months ago

This hacs integegration works with 2024.4 forecasts https://github.com/mlamberts78/weather-chart-card

That doesn't seem to show hourly forcasts

image

mbrevda commented 3 months ago

Oh, cool! Thanks for correcting me 🙏