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.45k stars 30.69k forks source link

weather.get_forecasts throws an error when type is not supported #104999

Closed TheFes closed 11 months ago

TheFes commented 11 months ago

The problem

The new weather.get_forecasts service call throws an error if you use it on an entity which doesn't support the specific type. This is the same behavior as the weather.get_forecast service call had, but as you can now ask for multiple entities, it will not give a result for any of the entities if one of the entities is unavailable for some reason.

It would be much better if there would be an empty list in case the type is not supported. This will make it possible to handle the response for all entities the same.

So example response

response:
  weather.openweathermap:
    forecast: []
  weather.met:
    forecast:
      - condition: snowy-rainy
        datetime: "2023-12-04T12:00:00+00:00"
        wind_bearing: 142.7
        cloud_coverage: 100
        temperature: 2.5
        wind_speed: 20.5
        precipitation: 0.4
        humidity: 83
  weather.tomorrow_io:
    forecast:
      - datetime: "2023-12-04T12:00:00+00:00"
        condition: fog
        precipitation_probability: 0
        wind_bearing: 141.88
        temperature: 2.6
        dew_point: -0.1
        wind_speed: 19.8
        precipitation: 0
        humidity: 83

What version of Home Assistant Core has the issue?

2023.12.0b1

What was the last working version of Home Assistant Core?

NA

What type of installation are you running?

Home Assistant OS

Integration causing the issue

weather

Link to integration documentation on our website

https://rc.home-assistant.io/integrations/weather

Diagnostics information

No response

Example YAML snippet

service: weather.get_forecasts
data:
  type: hourly
target:
  entity_id:
    - weather.openweathermap
    - weather.met
    - weather.accuweather

Anything in the logs that might be useful for us?

websocket_api script: Error executing script. Error for call_service at pos 1: Weather entity 'weather.openweathermap' does not support 'hourly' forecast

Additional information

No response

home-assistant[bot] commented 11 months ago

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (weather) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `weather` 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 weather` 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)


weather documentation weather source (message by IssueLinks)

MartinHjelmare commented 11 months ago

Core and frontend teams discussed this in a meeting today. We want to still raise an exception as soon as any entity does not support the service call.

We think it's better to notify the user clearly that something in the service call is not correct and what that is, than to return an empty list for an entity, which isn't clear why that happened.

TheFes commented 11 months ago

Thanks for the feedback 👍🏼