* Avoid duplicate timestamp conversions for websocket api and recorder
We convert the time from datetime to timestamps one per
open websocket connection and the recorder for every
state update. Only do the conversion once since its
~30% of the cost of building the state diff
* more
* two more
* two more in live history
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
* Use ulid-transform for constructing ulids
A future PR will use the new library to reduce the storage
overhead of ulids in the database
* tweak
* tweak
* bump
* Restore previous behavior of only waiting for new tasks at shutdown
* cleanup
* do a swap instead
* await canceled tasks
* await canceled tasks
* fix
* not needed since we no longer clear
* log it
* reword
* wait for airvisual
* tests
* Use a set for config entries task tracking
* Allow adding background tasks to config entries
* Add tests for config entry add tasks
* Update docstrings on core create task
* Migrate roon and august
* Use in more places
* Guard for None
* Keep task references while running
* Update pilight tests pointing at correct logger call
* Fix graphite tests
* Fix profiler tests
* More graphite test fixes
* Remove extra sleep
* Fix tests
* Shutdown background tasks as part of stage 1
* Remove unnecessary sleep in test
* Remove unused method on mock hass
* Skip on cancelled too
* Remove background tasks
* Test trigger variables without actually sleeping
* Fix graphite
* One more graphite grrrrrrr
* Speed up comparing State and Event objects
Use default python implementation for State and Event __hash__ and __eq__
The default implementation compared based on the id() of the object
which is effectively what we want here anyways. These overrides are
left over from the days when these used to be attrs objects
By avoiding implementing these ourselves all of the equality checks
can happen in native code
* tweak
* adjust tests
* write out some more
* fix test to not compare objects
* more test fixes
* more test fixes
* correct stats tests
* fix more tests
* fix more tests
* update sensor recorder tests