Commit graph

1879 commits

Author SHA1 Message Date
Marc Mueller
8a48d54951
Improve entity_platform helper typing (#75464)
* Improve entity_platform helper typing

* Add protocol class

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-07-20 05:45:57 +02:00
Marc Mueller
1626c53c13
Improve dispatcher helper typing (#75455)
* Improve dispatcher helper typing

* Code review
2022-07-20 04:11:46 +02:00
Marc Mueller
d09fff595c
Rename existing TypeVars referencing Self type (#75473) 2022-07-20 03:03:22 +02:00
Marc Mueller
b04c3e9adc
Improve deprecation helper typing (#75453) 2022-07-20 02:54:46 +02:00
Marc Mueller
5ae5ae5392
Improve debouncer typing (#75436) 2022-07-19 18:35:04 +02:00
Franck Nijhof
e65018fb85
Clean up deprecated connection class remainders (#75421) 2022-07-18 21:14:41 -07:00
Franck Nijhof
7adb0f0ef5
Custom component -> Custom integration (#75404) 2022-07-18 22:10:22 +02:00
J. Nick Koston
ba8a530d19
Use shared bluetooth models for BluetoothServiceInfo (#75322) 2022-07-16 21:14:23 -07:00
J. Nick Koston
ecc219fbc1
Include the source in the bluetooth service info (#75112) 2022-07-16 11:02:08 -05:00
J. Nick Koston
03e3ebb238
Use json_loads by default for the aiohttp helper (#75214) 2022-07-14 15:37:12 -05:00
J. Nick Koston
61cc9f5288
Consolidate executor jobs when loading integration manifests (#75176) 2022-07-14 13:06:08 -07:00
J. Nick Koston
fde3489e86
Relocate BluetoothServiceInfo to helpers.service_info (#75195) 2022-07-14 11:36:54 -07:00
J. Nick Koston
666f715e76
Avoid importing MQTT into core for ServiceInfo dataclass (#74418)
* Avoid importing MQTT into core for discovery dataclass

Likely fixes #73863

* relo

* adjust

* rename

* rename

* rename

* adjust missed imports

* drop compat

* fix conflict correctly

* Update homeassistant/helpers/config_entry_flow.py

* fix black from trying to fix the conflict in github
2022-07-14 11:09:09 -05:00
Erik Montnemery
2e228b2608
Tweak handling of entities with has_entity_name set (#74948)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2022-07-11 15:10:53 -07:00
J. Nick Koston
da027fa390
JSON serialize NamedTuple subclasses with aiohttp (#74971) 2022-07-11 14:46:55 -07:00
Allen Porter
f4e61eff18
Add update coordinator for google calendar (#74690)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-07-10 21:24:52 -07:00
epenet
16900dcef1
Make Store a generic class (#74617) 2022-07-09 22:32:57 +02:00
J. Nick Koston
a697672944
Add bluetooth integration (#74653)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-07-08 18:55:31 -05:00
J. Nick Koston
1dd9e705f2
Switch dispatcher to use async_run_hass_job (#74514)
* 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
2022-07-07 10:39:05 -05:00
J. Nick Koston
e7b2d4672c
Avoid loading mqtt for type checking (#74464) 2022-07-05 10:27:27 -07:00
J. Nick Koston
6c3baf03aa
Make dispatcher setup lazy (#74374) 2022-07-04 14:58:35 +02:00
J. Nick Koston
e2fe1a1c5d
Allow tuple subclasses to be json serialized (#74207) 2022-06-29 19:14:56 -05:00
Erik Montnemery
00810235c9
Track tasks adding entities (#73828)
* Track tasks adding entities

* Update homeassistant/config_entries.py

* fix cast tests

Co-authored-by: J. Nick Koston <nick@koston.org>
2022-06-29 09:38:35 +02:00
Erik Montnemery
146ff83a16
Migrate rest binary_sensor and switch to TemplateEntity (#73307) 2022-06-28 13:53:38 -07:00
J. Nick Koston
a8349a4866
Adjust entity filters to make includes stronger than excludes (#74080)
* Adjust entity filters to make includes stronger than excludes

Fixes #59080

* adjust test for stronger entity glob includes

* sync with docs
2022-06-28 11:42:51 -05:00
Erik Montnemery
26a85c6644
Add Entity.has_entity_name attribute (#73217) 2022-06-28 09:38:05 -07:00
J. Nick Koston
2225d0e899
Enable serialization of float subclasses with orjson (#74136) 2022-06-28 17:07:40 +02:00
[pʲɵs]
0e9164b082
Add bool template filter and function (#74068)
Co-authored-by: Erik <erik@montnemery.com>
2022-06-28 16:22:09 +02:00
J. Nick Koston
949922ef2c
Fix exception when as_dict is called on a TemplateState (#73984) 2022-06-25 09:19:11 -07:00
J. Nick Koston
32e0d9f47c
Speed up generation of template states (#73728)
* 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>
2022-06-24 17:28:26 -04:00
J. Nick Koston
edb386c736
Switch frontend to use json helper (#73874) 2022-06-23 20:19:13 +02:00
J. Nick Koston
8015bb98a9
Switch recorder and templates to use json helper (#73876)
- 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
2022-06-23 14:32:26 +02:00
J. Nick Koston
164eba7e5d
Switch loader to use json helper (#73872) 2022-06-22 21:57:38 -05:00
J. Nick Koston
ab30d38469
Switch rest to use the json helper (#73867) 2022-06-22 20:12:48 -05:00
Franck Nijhof
a8a033681f
Automatically onboard DiscoveryFlows (#73841) 2022-06-22 22:37:49 +02:00
J. Nick Koston
8b067e83f7
Initial orjson support take 3 (#73849)
* 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
2022-06-22 21:59:51 +02:00
epenet
a92105171c
Remove vizio from mypy ignore list (#73585)
* Remove vizio config_flow from mypy ignore list

* Fix mypy errors

* Adjust media_player

* Add space
2022-06-19 21:39:24 +02:00
Allen Porter
b014d558ff
Add application credentials platform for nest and deprecate yaml for SDM API (#73050)
* 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>
2022-06-15 07:15:53 -07:00
J. Nick Koston
9b157f974d
Reduce overhead to refire events from async_track_point_in_utc_time when an asyncio timer fires early (#73295)
* 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
2022-06-14 07:46:00 -10:00
J. Nick Koston
034c0c0593
Improve YAML Dump times with C Dumper (#73424) 2022-06-13 13:14:30 -07:00
Erik Montnemery
4435c641de
Enforce RegistryEntryHider in entity registry (#73219) 2022-06-08 12:36:43 -07:00
Erik Montnemery
921245a490
Remove deprecated temperature conversion of non sensors (#73222) 2022-06-08 20:47:47 +02:00
Erik Montnemery
5987266e56
Refactor template entity to allow reuse (#72753)
* 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
2022-06-08 15:55:49 +02:00
epenet
f91aa33c5f
Add FlowResultType enum to data entry flow (#72955) 2022-06-07 22:02:44 -07:00
Marc Mueller
983a76a91c
Update pylint to 2.14.0 (#73119) 2022-06-06 21:43:47 +02:00
Raphaël Beamonte
88129dbe91
Allow log template function to return specified default on math domain error (#72960)
Fix regression for logarithm template
2022-06-03 15:27:10 +02:00
Joakim Plate
8910d265d6
Keep track of a context for each listener (#72702)
* Remove async_remove_listener

This avoids the ambuigity as to what happens if same callback is added multiple times.

* Keep track of a context for each listener

This allow a update coordinator to adapt what data to request on update from the backing service based on which entities are enabled.

* Clone list before calling callbacks

The callbacks can end up unregistering and modifying the dict while iterating.

* Only yield actual values

* Add a test for update context

* Factor out iteration of _listeners to helper

* Verify context is passed to coordinator

* Switch to Any as type instead of object

* Remove function which use was dropped earliers

The use was removed in 8bee25c938
2022-06-03 13:55:57 +02:00
J. Nick Koston
c365454afb
Revert "Initial orjson support (#72754)" (#72789)
This was causing the wheels to fail to build. We need
to workout why when we don't have release pressure

This reverts commit d9d22a9556.
2022-05-31 13:51:55 -07:00
Joakim Plate
84779482b8
Don't set headers kwargs multiple times (#72779) 2022-05-31 13:08:50 -07:00
J. Nick Koston
d9d22a9556
Initial orjson support (#72754) 2022-05-31 12:18:11 -07:00