Avoid constructing an inner function each time we call async_listen
and use a partial which holds a reference to the function body with new
args instead of making another full function
* add supports_response to platform entity services
* support multiple entities in entity_service_call
* support legacy response format for service calls
* revert changes to script/shell_command
* add back test for multiple responses for legacy service
* remove SupportsResponse.ONLY_LEGACY
* Apply suggestion
Co-authored-by: Allen Porter <allen.porter@gmail.com>
* test for entity_id remove None
* revert Apply suggestion
* return EntityServiceResponse from _handle_entity_call
* Use asyncio.gather
* EntityServiceResponse not Optional
* styling
---------
Co-authored-by: Allen Porter <allen.porter@gmail.com>
* Avoid looking up the callable type for HassJob when we already know it
When we connect the frontend we call async_listen with run_immediately MANY
times when we already know the job type (it will always be a callback). This
reduces the latency to get the frontend going
* missing coverage
* Improve service response data APIs
Make the API naming more consistent, and require registration that a
service supports response data so that we can better integrate with
the UI and avoid user confusion with better error messages.
* Improve test coverage
* Add an enum for registering response values
* Assign enum values
* Convert SupportsResponse to StrEnum
* Update service call test docstrings
* Add tiny missing full stop in comment
---------
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
* Add support for service calls with resopnse data.
Update the service calls to allow returning responses with data,
with an initial use case supporting basic service calls usable
within script.
* Revert enttiy platform/component changes
* Remove unnecessary comma diff
* Revert additional unnecessary changes
* Simplify service call
* Simplify and fix typing and revert whitespace
* Clarify typing intent
* Revert more entity service calls
* Revert additional entity service changes
* Set blocking=True for group notify service call
* Revert unnecessary changes
* Reverting more whitespace changes
* Revert more service changes
* Add test coverage for None return case
* Add parameter to service calls indicating return values were requested
* Update tests/test_core.py
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
* Add additional service call tests
* Update test comment
---------
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
* Update return signature of service calls
* Add timeout error handling in websocket api for service calls
* Update recorder tests to remove assertion on service call
* Remove timeout behavior and update callers that depend on it today
* Fix tests
* Add missing else
* await coro directly
* Fix more tests
* Update the intent task to use wait instead of timeout
* Remove script service call limits and limit constants
* Update tests that depend on service call limits
* Use wait instead of wait_for and add test
* Update homeassistant/helpers/intent.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
---------
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Remove as_compressed_state cache
All calls to as_compressed_state are now covered by a higher level
JSON cache so there is no need to store these in memory anymore
* Remove as_compressed_state cache
All calls to as_compressed_state are now covered by a higher level
JSON cache so there is no need to store these in memory anymore