* Switch dispatcher to use async_run_hass_job
- Since we already wrap all the callbacks in catch_log_exception
we can use async_run_hass_job here
- The overhead of wrapping the call in a call_soon, queuing it
and running it later usually exceeds the overhead of running
the job itself
* fix size change during iteration
* fix out of order send
* fix missing mocking in unifi test
* Fix Legrand Home+ Control updating entities before the coordinator update had finished
* stray debug
* Speed up generation of template states
* tweak
* cache
* cache hash
* weaken
* Revert "weaken"
This reverts commit 4856f50080.
* lower cache size as it tends to be the same ones over and over
* lower cache size as it tends to be the same ones over and over
* lower cache size as it tends to be the same ones over and over
* cover
* Update homeassistant/helpers/template.py
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
* id reuse is possible
* account for iterting all sensors
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
- These were using orjson directly, its a bit cleaner
to use the helper so everything is easier to adjust
in the future if we need to change anything about
the loading
* Initial orjson support take 2
Still need to work out problem building wheels
--
Redux of #72754 / #32153 Now possible since the following is solved:
ijl/orjson#220 (comment)
This implements orjson where we use our default encoder. This does not implement orjson where `ExtendedJSONEncoder` is used as these areas tend to be called far less frequently. If its desired, this could be done in a followup, but it seemed like a case of diminishing returns (except maybe for large diagnostics files, or traces, but those are not expected to be downloaded frequently).
Areas where this makes a perceptible difference:
- Anything that subscribes to entities (Initial subscribe_entities payload)
- Initial download of registries on first connection / restore
- History queries
- Saving states to the database
- Large logbook queries
- Anything that subscribes to events (appdaemon)
Cavets:
orjson supports serializing dataclasses natively (and much faster) which
eliminates the need to implement `as_dict` in many places
when the data is already in a dataclass. This works
well as long as all the data in the dataclass can also
be serialized. I audited all places where we have an `as_dict`
for a dataclass and found only backups needs to be adjusted (support for `Path` needed to be added for backups). I was a little bit worried about `SensorExtraStoredData` with `Decimal` but it all seems to work out from since it converts it before it gets to the json encoding cc @dgomes
If it turns out to be a problem we can disable this
with option |= [orjson.OPT_PASSTHROUGH_DATACLASS](https://github.com/ijl/orjson#opt_passthrough_dataclass) and it
will fallback to `as_dict`
Its quite impressive for history queries
<img width="1271" alt="Screen_Shot_2022-05-30_at_23_46_30" src="https://user-images.githubusercontent.com/663432/171145699-661ad9db-d91d-4b2d-9c1a-9d7866c03a73.png">
* use for views as well
* handle UnicodeEncodeError
* tweak
* DRY
* DRY
* not needed
* fix tests
* Update tests/components/http/test_view.py
* Update tests/components/http/test_view.py
* black
* templates
* Update the nest integration to be useable fully from the config flow
* Support discovery in nest config flow
* Remove configuration entries
* Remove unused import
* Remove dead code
* Update homeassistant/components/nest/strings.json
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Remove commented out code
* Use config flow for app auth reauthentication path
* Improves for re-auth for upgrading existing project and creds
* More dead code removal
* Apply suggestions from code review
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Remove outdated code
* Update homeassistant/components/nest/config_flow.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Reduce overhead to refire events
- asyncio timers can fire early for a varity of reasons including
poor clock resolution and performance. To solve this problem
we re-arm async_track_point_in_utc_time and try again later
when this happens.
- On some platforms this means the async_track_point_in_utc_time can
end up trying many times to prevent firing the timer early since as
soon as it rearms it fires again and this repeats until we reach
the appointed time. While there is not much we can do to prevent
asyncio from firing the timer callback early, we can reduce the
overhead when this happens by using avoiding creating datetime
objects
* tweak mocking
* -vvv
* fix time freeze being too broad in litterrobot
* adjust
* Refactor template entity to allow reuse
* Fix schema and default name
* Add tests
* Update requirements
* Improve test
* Tweak TemplateSensor initializer
* Drop attributes and availability from TemplateEntity
* Use rest sensor for proof of concept
* Revert changes in SNMP sensor
* Don't set _attr_should_poll in mixin class
* Update requirements