1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-22 20:09:35 +00:00
Commit Graph

3274 Commits

Author SHA1 Message Date
J. Nick Koston
9381462877 Migrate restore_state to use the singleton helper (#117385) 2024-05-14 09:13:44 +09:00
J. Nick Koston
f318a3b5e2 Fix blocking I/O in the event loop to get MacOS system_info (#117290)
* Fix blocking I/O in the event look to get MacOS system_info

* split pr

* Update homeassistant/helpers/system_info.py

Co-authored-by: Jan-Philipp Benecke <jan-philipp@bnck.me>

* Update homeassistant/helpers/system_info.py

---------

Co-authored-by: Jan-Philipp Benecke <jan-philipp@bnck.me>
2024-05-12 08:16:21 -04:00
J. Nick Koston
eac4aaef10 Use a dictcomp to reconstruct DeviceInfo in the device_registry (#117286)
Use a dictcomp to reconstruct DeviceInfo

a dictcomp is faster than many sets on the dict by at least
25%

We call this for nearly every device in the registry at
startup
2024-05-12 08:07:12 +02:00
J. Nick Koston
b061e7d1aa Small speed up to setting up integrations and config entries (#117278)
* Small speed up to setting up integration and config entries

When profiling tests, I noticed many calls to get_running_loop. In the places
where we are already in a coro, pass the existing loop so it does not have to
be looked up. I did not do this for places were we are not in a coro since there
is risk that an integration could be doing a non-thread-safe call and its better
that the code raises when trying to fetch the running loop vs the performance
improvement for these cases.

* fix merge

* missed some
2024-05-11 22:39:20 -04:00
J. Nick Koston
d7aa24fa50 Only load translations for an integration once per test session (#117118) 2024-05-11 12:00:02 +09:00
Marc Mueller
04c0b7d3df Use HassKey for importlib helper (#117116) 2024-05-08 17:42:28 -05:00
Sid
ac54cdcdb4 Enable Ruff RUF010 (#115371)
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-05-08 23:54:49 +02:00
J. Nick Koston
03dcede211 Avoid creating inner tasks to load storage (#117099) 2024-05-08 23:41:20 +02:00
J. Nick Koston
84a91a86a9 Improve config entry has already been setup error message (#117091) 2024-05-08 14:16:08 -05:00
Troon
cc99a9b62a Add an add template filter (#109884)
* Addition of add filter

This change adds an `add` filter, the addition equivalent of the existing `multiply` filter.

* Test for add filter

* Update test_template.py

* Update tests/helpers/test_template.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-05-08 15:39:36 +02:00
Michael Hansen
7923471b94 Intent target matching and media player enhancements (#115445)
* Working

* Tests are passing

* Fix climate

* Requested changes from review
2024-05-07 22:01:03 -04:00
J. Nick Koston
8401b05d40 Move thread safety check in category_registry sooner (#117050) 2024-05-07 19:55:43 -05:00
J. Nick Koston
0b2c29fdb9 Move thread safety in floor_registry sooner (#117044) 2024-05-07 18:48:38 -05:00
J. Nick Koston
fc3c384e0a Move thread safety in label_registry sooner (#117026) 2024-05-07 15:15:30 -05:00
J. Nick Koston
26cc1cd3db Use singleton helper for registries (#117027) 2024-05-07 21:04:01 +02:00
Marc Mueller
f9e2ab2e81 Improve issue_registry event typing (#117023) 2024-05-07 19:49:02 +02:00
Marc Mueller
018e7731ae Add SignificantChangeProtocol to improve platform typing (#117002) 2024-05-07 18:40:57 +02:00
Marc Mueller
2db64c7e6d Use HassKey for helpers (1) (#117012) 2024-05-07 11:25:16 -05:00
Marc Mueller
8f614fb06d Use HassKey for helpers (2) (#117013) 2024-05-07 11:24:13 -05:00
Marc Mueller
fd5885ec83 Use HassKey for registries (#117000) 2024-05-07 18:03:14 +02:00
Sid
2cc916db6d Replace pylint broad-except with Ruff BLE001 (#116250) 2024-05-07 14:00:27 +02:00
Marc Mueller
3d700e2b71 Add HassDict implementation (#103844) 2024-05-07 10:53:13 +02:00
Sid
b456d97e65 Replace pylint protected-access with Ruff SLF001 (#115735) 2024-05-06 20:33:26 +02:00
J. Nick Koston
5d5f311898 Move thread safety check in issue_registry sooner (#116899) 2024-05-05 20:32:55 -05:00
J. Nick Koston
91fa8b50cc Turn on thread safety checks in async_dispatcher_send (#116867)
* Turn on thread safety checks in async_dispatcher_send

We keep seeing issues where async_dispatcher_send is called from
a thread which means we call the callback function on the other
side in the thread as well which usually leads to a crash

* Turn on thread safety checks in async_dispatcher_send

We keep seeing issues where async_dispatcher_send is called from
a thread which means we call the callback function on the other
side in the thread as well which usually leads to a crash

* adjust
2024-05-05 16:29:43 -04:00
J. Nick Koston
b41b1bb998 Refactor entity_platform polling to avoid double time fetch (#116877)
* Refactor entity_platform polling to avoid double time fetch

Replace async_track_time_interval with loop.call_later
to avoid the useless time fetch every time the listener
fired since we always throw it away

* fix test
2024-05-05 16:28:01 -04:00
J. Nick Koston
0380116ef6 Improve logging of _TrackPointUTCTime objects (#116711) 2024-05-04 17:35:44 -05:00
Jan Bouwhuis
84308c9e53 Add title feature to notify entity platform (#116426)
* Add title feature to notify entity platform

* Add overload variants

* Remove overloads, update signatures

* Improve test coverage

* Apply suggestions from code review

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

* Do not use const

* fix typo

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-05-03 11:17:28 +02:00
J. Nick Koston
2401580b6f Make a copy of capability_attributes instead of making a new dict (#116477) 2024-04-30 17:54:33 -05:00
G Johansson
822646749d Remove entity category "system" check from entity registry (#116412) 2024-04-30 04:01:12 +02:00
J. Nick Koston
164403de20 Add thread safety checks to async_create_task (#116339)
* 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
2024-04-28 18:29:00 -04:00
J. Nick Koston
ab2ea6100c Speed up singleton decorator so it can be used more places (#116292) 2024-04-28 12:11:08 -05:00
J. Nick Koston
66e86170b1 Make storage load tasks background tasks to avoid delaying shutdown (#116332) 2024-04-28 08:14:15 -05:00
J. Nick Koston
76639252c9 Make discovery flow tasks background tasks (#116327) 2024-04-28 08:13:37 -05:00
J. Nick Koston
cbcfd71f3d Reduce number of time calls needed to write state (#116297) 2024-04-27 13:17:31 -05:00
J. Nick Koston
f295172d07 Add a fast path for _stringify_state when state is already a str (#116295) 2024-04-27 10:48:17 -05:00
J. Nick Koston
eea66921bb Avoid update call in entity state write if there is no customize data (#116296) 2024-04-27 10:48:05 -05:00
J. Nick Koston
7715bee6b0 Fix script in restart mode that is fired from the same trigger (#116247) 2024-04-27 07:08:29 -05:00
J. Nick Koston
b403c9f92e Move thread safety check in area_registry sooner (#116265)
It turns out we have custom components that are writing to the area registry using the async APIs from threads. We now catch it at the point async_fire is called. Instead we should check sooner and use async_fire_internal so we catch the unsafe operation before it can corrupt the registry.
2024-04-27 09:26:35 +02:00
J. Nick Koston
244433aeca Move thread safety check in entity_registry sooner (#116263)
* Move thread safety check in entity_registry sooner

It turns out we have a lot of custom components that are writing
to the entity registry using the async APIs from threads. We now
catch it at the point async_fire is called. Instread we should check
sooner and use async_fire_internal so we catch the unsafe operation
before it can corrupt the registry.

* coverage

* Apply suggestions from code review
2024-04-27 09:25:19 +02:00
J. Nick Koston
09ebbfa0e1 Move thread safety check in device_registry sooner (#116264)
It turns out we have custom components that are writing to the device registry using the async APIs from threads. We now catch it at the point async_fire is called. Instead we should check sooner and use async_fire_internal so we catch the unsafe operation before it can corrupt the registry.
2024-04-27 09:24:55 +02:00
Sid
e662e3b65c Bump ruff to 0.4.2 (#116201)
* Bump ruff to 0.4.2

* review comments
2024-04-26 08:48:32 +02:00
Erik Montnemery
623d34e1e0 Remove early return when validating entity registry items (#116160) 2024-04-26 08:38:24 +02:00
Jan Bouwhuis
372c6c7874 Use existing monotonic timestamp on mqtt messages for debugging (#116196) 2024-04-25 19:09:54 -05:00
Erik Montnemery
6bff0c384f Remove deprecation warnings for relative_time (#116144)
* Remove deprecation warnings for relative_time

* Update homeassistant/helpers/template.py

Co-authored-by: Simon <80467011+sorgfresser@users.noreply.github.com>

---------

Co-authored-by: Simon <80467011+sorgfresser@users.noreply.github.com>
2024-04-25 13:02:18 +02:00
Erik Montnemery
2e88ba40ff Fix lying docstring for relative_time template function (#116146)
* Fix lying docstring for relative_time template function

* Update homeassistant/helpers/template.py

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

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-25 13:01:41 +02:00
J. Nick Koston
df12789e08 Remove duplicate async_write_ha_state thread safety check (#116086) 2024-04-24 12:46:16 +02:00
rlippmann
1120246194 Deprecate relative_time() in favor of time_since() and time_until() (#111177)
* add time_since/time_until.  add deprecation of relative_time

* fix merge conflicts

* Apply suggestions from code review

* Update homeassistant/helpers/template.py

* Update homeassistant/helpers/template.py

* Update homeassistant/helpers/template.py

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-04-24 11:13:07 +02:00
J. Nick Koston
79b4889812 Always do thread safety checks when writing state for custom components (#116044) 2024-04-24 10:05:52 +02:00
Robert Resch
a4829330f6 Add strict connection for cloud (#115814)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-04-24 09:57:38 +02:00