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
71.11k stars 29.79k forks source link

OpenWeatherMap forecast cannot be used outside HA #121219

Open oskars-viksna opened 2 months ago

oskars-viksna commented 2 months ago

The problem

Recent change (https://github.com/home-assistant/core/pull/119922) has removed ability to read forecast via sensor, but now requires to call a service. Unfortunately calling service from outside of HA is completely broken for now - any call outside of HA ends with an error 500 and error message homeassistant.exceptions.ServiceValidationError: The service call requires responses and must be called with return_response=True. There same issue is described here - https://community.home-assistant.io/t/cant-call-service-that-returns-response/730859/11. Service call from inside of HA works, for example from Developer section. So this removal of sensors now completely breaks ability to display and use forecast data outside of HA. Please restore sensors while calling HA services is fixed.

What version of Home Assistant Core has the issue?

2024.7.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

OpenWeatherMap

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

curl -H "Authorization: Bearer TOKEN" -H "Content-Type: application/json" -d '{"device_id": <ID>, "return_response": "True"}' http://localhost:8123/api/services/weather/get_forecasts

Anything in the logs that might be useful for us?

2024-07-04 17:28:11.640 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/api/__init__.py", line 406, in post
    await shield(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2685, in async_call
    raise ServiceValidationError(
homeassistant.exceptions.ServiceValidationError: The service call requires responses and must be called with return_response=True

Additional information

No response

home-assistant[bot] commented 1 month ago

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

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


openweathermap documentation openweathermap source (message by IssueLinks)

freekode commented 1 month ago

here you can find how you can create your own sensors based on service call https://www.home-assistant.io/integrations/template/#trigger-based-handling-of-action-response-data