home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.46k stars 30.69k forks source link

Unsure How To Use Hourly Forecast Information (Since 2024.3.0) #112628

Closed colinhatfield closed 7 months ago

colinhatfield commented 8 months ago

The problem

Since updating to 2024.3.0 I'm unsure how to use hourly forecast information.

Previously the weather.forecast_hourly entity had attributes for each hour of the day, these could then be displayed on cards etc (I used a template like state_attr('weather.forecast_home','hourly')[0])['temperature'] for example).

Now only the weather.forecast_home exists, and I can only see the daily attributes for the entity.

I can see the hourly data by navigating to the service itself:

Hourly

but I can't figure out how to use this data.

Any advice would be greatly appreciated

What version of Home Assistant Core has the issue?

2024.3.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

met

Link to integration documentation on our website

https://www.home-assistant.io/integrations/met

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

Entity Attributes:

friendly_name: Forecast Home supported_features: 3 temperature: 6.9 dew_point: 3.4 temperature_unit: °C humidity: 78 cloud_coverage: 100 pressure: 1022.3 pressure_unit: hPa wind_bearing: 95.9 wind_speed: 14.98 wind_speed_unit: mph visibility_unit: mi precipitation_unit: mm forecast:

attribution: Weather forecast from met.no, delivered by the Norwegian Meteorological Institute.

home-assistant[bot] commented 8 months ago

Hey there @danielhiversen, mind taking a look at this issue as it has been labeled with an integration (met) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `met` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign met` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


met documentation met source (message by IssueLinks)

zigomatichub commented 8 months ago

I think it's link with this change https://github.com/home-assistant/core/pull/111863

I'm also using this entity in my e-paper screen.

badewanne1234 commented 8 months ago

Same here. Honestly I was expecting to receive the hourly attributes in the entity since it was mentioned in the blog post (unforutnately I did not check the github issues before updating... So the data is somewhere, but unusable at the moment :(

bzzzggz commented 8 months ago

I have the same issue; all hourly weather-based automation failed now.

peterjuras commented 8 months ago

I was also surprised by this, I hope there is a workaround to get the hourly information since I had this on my main dashboard.

Why was this not listed in the backwards incompatible changes list of the 2024.03 release?

Edit: At least for the weather card, I was able to change the display configuration to display hourly, so it works correctly again for me. I'd still appreciate it if entity removals would be listed in backwards incompatible changes.

Edit 2: My mistake! 🙏 The breaking changes were listed in the "Met.no" integration, I just didn't make the connection between my weather entity that I have since day one and the Met.no integration :)

GozuMezu commented 8 months ago

I'm also interrested in learning how I can access the hourly data in this new structure (e.g. {% for state in states.weather.home_hourly.attributes.forecast[0:1] -%} I was very grateful for the data I could get from this - I spent a lot of time making a 24 led ring light where the colour of each light represents the predicted temperature and the intensity with which the led flashes shows the likelihood of rain for that hour... .

Thanks to anyone who can point me in the right direction for this...

QuadrifoglioVerde commented 8 months ago

maybe this helps to someone:

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

image

tommywestside commented 8 months ago

maybe this helps to someone, extract hourly forecast into new sensor as attributes: template: - trigger: - platform: time_pattern hours: /1 - platform: homeassistant event: start action: - service: weather.get_forecasts data: type: hourly target: entity_id: weather.home response_variable: hourly sensor: - name: Weather Hourly state: "{{ hourly['weather.home'].forecast[0].temperature }}" attributes: forecast: "{{ hourly['weather.home'].forecast }}"

image

Awesome, thanks! Was just about to start looking into something like this myself...

badewanne1234 commented 8 months ago

This is all awesome with the workaround and I'll give it a go but I really wonder if this is a bug or intended @Danielhiversen ?

adorobis commented 8 months ago

maybe this helps to someone

Great, many thanks, works as expected!

colinmcintosh commented 8 months ago

Tagging the person who committed this change... @emontnemery are you able to share some details on how the hourly forecast is intended to be accessed?

MisterRadish commented 8 months ago

So glad I found this thread - I have been tearing my hair out. Will try the work around and I hope it gets fixed soon.

stovedoctor commented 8 months ago

I tried the templet above but I got Forecast NULL. Screenshot 2024-03-11 105115

dew_point: 40
temperature_unit: °F
humidity: 64
cloud_coverage: 12.5
pressure: 30.06
pressure_unit: inHg
wind_bearing: 207.1
wind_speed: 3.6
wind_speed_unit: mph
visibility_unit: mi
precipitation_unit: in
forecast: null
friendly_name: Weather Hourly```

My templet

#weather forcast hourly sensor 
- trigger:
    - platform: time_pattern
      hours: /1
    - platform: homeassistant
      event: start
  action:
    - service: weather.get_forecasts
      data:
        type: hourly
      target:
        entity_id: weather.home
      response_variable: hourly

- sensor:
    - name: Weather Hourly
      state: "{{ states('weather.home') }}"
      attributes:
        temperature: "{{ state_attr('weather.home', 'temperature') }}"
        dew_point: "{{ state_attr('weather.home', 'dew_point') }}"
        temperature_unit: "{{ state_attr('weather.home', 'temperature_unit') }}"
        humidity: "{{ state_attr('weather.home', 'humidity') }}"
        cloud_coverage: "{{ state_attr('weather.home', 'cloud_coverage') }}"
        pressure: "{{ state_attr('weather.home', 'pressure') }}"
        pressure_unit: "{{ state_attr('weather.home', 'pressure_unit') }}"
        wind_bearing: "{{ state_attr('weather.home', 'wind_bearing') }}"
        wind_speed: "{{ state_attr('weather.home', 'wind_speed') }}"
        wind_speed_unit: "{{ state_attr('weather.home', 'wind_speed_unit') }}"
        visibility_unit: "{{ state_attr('weather.home', 'visibility_unit') }}"
        precipitation_unit: "{{ state_attr('weather.home', 'precipitation_unit') }}"
        forecast: "{{ hourly['weather.home'].forecast }}"    

Screenshot 2024-03-11 105608

QuadrifoglioVerde commented 8 months ago

Call service weather.get_forecasts manually (in dev tools) and check if there is any hourly forecast data.

stovedoctor commented 8 months ago

Call service weather.get_forecasts manually (in dev tools) and check if there is any hourly forecast data.

im not following? your screen shot shows the forcast and datetime mine just says null. what my goal is to fix my templets I had before the change to show +2 hour and so on weather forecast data to some screens. here is my old one and trying to figure out how to do with using the new service call way.

  - obj: "p5b21" # Forecast time +1h
      properties:
        "text": >
          {%- if not is_state('weather.barb_s_place_hourly','unavailable') %}
          {%- set update = states('sensor.date') %}
          {%- set midnight = now().replace(hour=0, minute=0, second=0, microsecond=0).timestamp() %}
          {%- set event = as_timestamp(strptime(state_attr('weather.barb_s_place_hourly','forecast')[1]['datetime'], '%Y-%m-%dT%H:%M:%S%z', default='2020-01-00T00:00:00+00:00')) %}
          {%- set delta = ((event - midnight) // 86400) | int %}
          {%- if delta == 0 %}
          Today
          {%- elif delta == 1 %}
          Tomorrow
          {%- endif %}
          {{- event | timestamp_custom(" %-I %p") }}
          {%- endif %}

    - obj: "p5b22" # Forecast temp +1h
      properties:
        "text": "{{ state_attr('weather.barb_s_place_hourly','forecast')[1]['temperature'] if not is_state('weather.barb_s_place_hourly','unavailable') else '-' }}"

    - obj: "p5b23" # Forecast condition +1h
      properties:
        "src": >
          {%- if not is_state('weather.barb_s_place_hourly','unavailable') %}
          L:/w-32-{{ state_attr('weather.barb_s_place_hourly','forecast')[1]['condition'] }}.png
          {%- endif %}

to show in a panel. 0f70e856a3799f169655384d8185769c252b5f5f_2_336x500

thanks ahead of time for the help.

QuadrifoglioVerde commented 8 months ago

image

stovedoctor commented 8 months ago

yes Screenshot 2024-03-11 115817

QuadrifoglioVerde commented 8 months ago

Ok, i see... remove "minus" sign before "sensor:"

stovedoctor commented 8 months ago

Ok, i see... remove "minus" sign before "sensor:" DUH that fixed it. see im a dumb ass. Now I have to figure out how to implement this in a way i did the the other templet to get +1 +2 +3 +4 and so on Again thanks for your help

stovedoctor commented 8 months ago

yhaa I got it.

     - obj: "p5b51" # Forecast time +8h
      properties:
        "text": >
          {%- if not is_state('sensor.weather_hourly','unavailable') %}
          {%- set update = states('sensor.date') %}
          {%- set midnight = now().replace(hour=0, minute=0, second=0, microsecond=0).timestamp() %}
          {%- set event = as_timestamp(strptime(state_attr('sensor.weather_hourly','forecast')[8]['datetime'], '%Y-%m-%dT%H:%M:%S%z', default='2020-01-00T00:00:00+00:00')) %}
          {%- set delta = ((event - midnight) // 86400) | int %}
          {%- if delta == 0 %}
          Today
          {%- elif delta == 1 %}
          Tomorrow
          {%- endif %}
          {{- event | timestamp_custom(" %-I %p") }}
          {%- endif %}

    - obj: "p5b52" # Forecast temp +8h
      properties:
        "text": "{{ state_attr('sensor.weather_hourly','forecast')[8]['temperature'] if not is_state('sensor.weather_hourly','unavailable') else '-' }}"

    - obj: "p5b53" # Forecast condition +8h
      properties:
        "src": >
          {%- if not is_state('sensor.weather_hourly','unavailable') %}
          L:/w-32-{{ state_attr('sensor.weather_hourly','forecast')[8]['condition'] }}.png
          {%- endif %}

workingweather

stovedoctor commented 8 months ago

I documented for my future self and others for help open hasp

martin3000 commented 7 months ago

See https://www.home-assistant.io/blog/2023/09/06/release-20239/#weather-forecast-service

joostlek commented 7 months ago

I must say, this doesn't look like an issue with the code but a support request. Please use the appropriate channels for that like discord or the forums.

I'll close the issue because of that reason

adorobis commented 7 months ago

this doesn't look like an issue with the code

I tend to disagree. The release notes state: "The met.no integration now only creates a single entity that provides both daily and hourly weather forecasts." but the hourly forecast attributes are missing. So it is either problem with the code that should be fixed or wrong information in the documenation.

joostlek commented 7 months ago

Just asked one of the people helping out with these kinds of issues and there are 2 forum threads talking about exactly this.

https://community.home-assistant.io/t/petition-dont-delete-the-forecast-attribute/609298/ https://community.home-assistant.io/t/how-to-migrate-from-weather-integration-approach-to-new-weather-get-forecast-service/619481/

I mean if there was an issue with the code (which you say there is) I would expect this issue not to be called "unsure how to use X" and have the content look like a forum post.

If you still do think there is an issue with the integration, please create a new issue with reproduction steps telling what steps you tried and what you expect what would happen.

adorobis commented 7 months ago

OK, looks like there is one already: https://github.com/home-assistant/core/issues/112583 Switching over to that one for either of the fixes.