-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for responses to call_service
WS cmd
#98610
Conversation
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
While easier for the caller to not have to supply additional input arguments, the previous call was to add an explicit parameter to request response values for performance (e.g. to avoid unnecessarily computing response values, or making a cloud call, etc, where they might not be needed). I think its worth considering either for consistency or performance how much worse this API is with an extra input argument for response values. Not adding it is a harder to reverse decision, but adding it is easier to reverse if we want to make it always in the future. (Having the argument as a pass through means this call also doesn't have to check whether or not it is supported, as it can use the existing check) |
I'm open to adding it as a parameter for consistency, and you are right, a lot of the logic changes are simpler as a result. |
Looks like this is a near duplicate of #95056. I think we can continue here, but if we merge here we should close that one. |
I think my only question here is about catching the |
doesn't look like we handle the ValueError's in the core, so maybe it would just be tests that need to be updated, and perhaps the frontend? |
We're kind of in an inconsistent state right now -- this discussion has a good summary: #78889 (comment) |
Yeah so I guess the question is how do we give WS clients a response that lets them know that the option that they provided in their call was not valid? That's essentially what the outcome is, but if catch this exception, it will catch some of those other scenarios that were being discussed in that PR. |
Thinking about this more, even though we return the unknown error code, which is probably not great, we also share the reason, so the caller can operate off of that. I'm going to remove the catch here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Proposed change
The
call_service
websocket API command did not previously support returning a response. With this change it does. A newreturn_response
parameter has been added to the WS command inputs that allows the caller to get a response from a service.Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: