Avoid addtional timestamp conversion to set state
Since we already have the timestamp, we can pass it on to the State
object and avoid the additional timestamp conversion which can be as
much as 30% of the state write runtime.
Since datetime objects are limited to microsecond precision, we need
to adjust some tests to account for the additional precision that we
will now be able to get in the database
* Reduce number of calls to last_reported_timestamp
When a state is created, last_update is always the same
as last_reported, and we only update it later if it changes
so we can pre-set the cached property to avoid it being
run when the recorder accesses it later.
* fix cache not being overridden
* coverage
* Refactor state_reported listener setup to avoid merge in async_fire_internal
Instead of merging the listeners in async_fire_internal, setup the listener for
state_changed at the same time so async_fire_internal can avoid having to copy
another list
* Refactor state_reported listener setup to avoid merge in async_fire_internal
Instead of merging the listeners in async_fire_internal, setup the listener for
state_changed at the same time so async_fire_internal can avoid having to copy
another list
* tweak
* tweak
* tweak
* tweak
* tweak
* Add thread safety checks to async_create_task
Calling async_create_task from a thread almost always results in an
fast crash. Since most internals are using async_create_background_task
or other task APIs, and this is the one integrations seem to get wrong
the most, add a thread safety check here
* Add thread safety checks to async_create_task
Calling async_create_task from a thread almost always results in an
fast crash. Since most internals are using async_create_background_task
or other task APIs, and this is the one integrations seem to get wrong
the most, add a thread safety check here
* missed one
* Update homeassistant/core.py
* fix mocks
* one more internal
* more places where internal can be used
* more places where internal can be used
* more places where internal can be used
* internal one more place since this is high volume and was already eager_start
* Small improvement to service validation exception test and translation key
* Apply suggestions from code review
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Refactor string assertion
---------
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Make release channel a hardcoded enum rather than a free form string
* Update enum comparison to remove equality and us identity comparison
* Fix comparison condition to match the previous implementation
* Update tests to use Enum instead of string
* Keep track of top level components
Currently we have to do a set comp for icons, translations,
and integration platforms every time to split the top level
components from the platforms. Keep track of the top level
components in a seperate set so avoid having to do the setcomp
every time.
* remove impossible paths
* remove unused code
* preen
* preen
* fix
* coverage and fixes
* Update homeassistant/core.py
* Update homeassistant/core.py
* Update tests/test_core.py
* DNM: Make run_immediately the default for listeners
This is a test to see how much progress we have made twords this goal
https://github.com/home-assistant/core/pull/113727#issuecomment-2004587947
* fix shutdown
* Revert "fix shutdown"
This reverts commit a8969d7db9.
* set false since it break utility meter tests
* one more
* fix rfxtrx test
* test needs to be explict now
* fix matrix
* fail sooner
* Mark executor jobs as background unless created from a tracked task
If the current task is not tracked the executor job should not
be a background task to avoid delaying startup and shutdown.
Currently any executor job created in a untracked task or
background task would end up being tracked and delaying
startup/shutdown
* import exec has the same issue
* Avoid tracking import executor jobs
There is no reason to track these jobs as they are always awaited
and we do not want to support fire and forget import executor jobs
* fix xiaomi_miio
* lots of fire time changed without background await
* revert changes moved to other PR
* more
* more
* more
* m
* m
* p
* fix fire and forget tests
* scrape
* sonos
* system
* more
* capture callback before block
* coverage
* more
* more races
* more races
* more
* missed some
* more fixes
* missed some more
* fix
* remove unneeded
* one more race
* two
Co-authored-by: Sid <27780930+autinerd@users.noreply.github.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
* Add restrictions for listening to event_reported events
* Update homeassistant/core.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
---------
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Fetch MaxLengthExceeded exception mesage from the translation cache
* Update homeassistant/components/homeassistant/strings.json
Co-authored-by: J. Nick Koston <nick@koston.org>
* Add case without homeassistant integration
* Fix test
---------
Co-authored-by: J. Nick Koston <nick@koston.org>
* Replace pylint pointless-statement with ruff B018
* fix occurrences of B018
* disable pylint expression-not-assigned as well
---------
Co-authored-by: J. Nick Koston <nick@koston.org>