Cannot call a service from AppDaemon when response data is wanted.
Service call fails when either method is used.
self.temp_forecast_entity = self.get_entity('weather.ksjc_daynight') response=self.temp_forecast_entity.call_service(service='get_forecasts', type='hourly', return_response=True)
or
response=self.call_service('weather/get_forecasts', entity_id = 'weather.forecast_home', type = 'hourly', return_response=True)
Appdaemon logs this
2024-05-20 16:37:10.625349 WARNING HASS: Code: 500, error: 500 Internal Server Error Server got itself in trouble
2024-05-20 16:37:10.622865 WARNING HASS: Error calling Home Assistant service default/weather/get_forecasts
homeassistant.log logs this
2024-05-20 16:37:10.605 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 88, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/aiohttp_session/__init__.py", line 199, in factory
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 295, 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 2692, in async_call
raise ServiceValidationError(
homeassistant.exceptions.ServiceValidationError: The service call requires responses and must be called with return_response=True
Relevant code in the app or config file that caused the issue
Service call fails when either method is used.
self.temp_forecast_entity = self.get_entity('weather.ksjc_daynight') response=self.temp_forecast_entity.call_service(service='get_forecasts', type='hourly', return_response=True)
or
response=self.call_service('weather/get_forecasts', entity_id = 'weather.forecast_home', type = 'hourly', return_response=True)
Anything else?
I've tried two different service calls on different integrations
I've also confirmed in the HA developer pane, the services work and return data.
My suspicion is that the "return_response=True" portion of the service call is getting lost though the API.
What happened?
Cannot call a service from AppDaemon when response data is wanted. Service call fails when either method is used.
self.temp_forecast_entity = self.get_entity('weather.ksjc_daynight') response=self.temp_forecast_entity.call_service(service='get_forecasts', type='hourly', return_response=True)
orresponse=self.call_service('weather/get_forecasts', entity_id = 'weather.forecast_home', type = 'hourly', return_response=True)
Full write up has been posted on the forum https://community.home-assistant.io/t/cant-call-service-that-returns-response/730859/7
Version
0.16.4
Installation type
Home Assistant add-on
Relevant log output
Relevant code in the app or config file that caused the issue
Anything else?
I've tried two different service calls on different integrations I've also confirmed in the HA developer pane, the services work and return data. My suspicion is that the "return_response=True" portion of the service call is getting lost though the API.