1
0
mirror of https://github.com/home-assistant/core.git synced 2025-05-15 11:29:15 +00:00

105 Commits

Author SHA1 Message Date
Erik Montnemery
7abffd7cc8
Don't report entities with invalid unique id when loading the entity registry () 2024-05-29 08:32:39 +02:00
J. Nick Koston
7871e9279b
Adjust thread safety check messages to point to developer docs () 2024-05-14 15:20:31 +02:00
G Johansson
822646749d
Remove entity category "system" check from entity registry () 2024-04-30 04:01:12 +02:00
J. Nick Koston
244433aeca
Move thread safety check in entity_registry sooner ()
* 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
Erik Montnemery
7c95ecff20
Validate unique_id in entity registry ()
Co-authored-by: Shay Levy <levyshay1@gmail.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-04-04 09:51:44 -10:00
J. Nick Koston
54a69a2687
Remove async_get_device_class_lookup from entity_registry ()
This function was only ever used in homekit, and since there is
now an index of devices in the entity registry, homekit no longer
uses it.

I searched github code for all references to async_get_device_class_lookup
and the only think I could find using it were forks of core. It seems
unlikely that any custom components are affected by removing this
function
2024-03-26 09:22:53 +01:00
Joost Lekkerkerker
6bb4e7d62c
Bump ruff to 0.3.4 ()
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>
2024-03-26 00:02:16 +01:00
Sid
727581eea3
Add first batch of Ruff PT rules ()
* Add first batch of Ruff PT rules

* fix weather test

* Fix pilight test

* Update test_intent.py

* Update pilight test_init.py

* Update test_init.py
2024-03-18 13:26:14 +01:00
Franck Nijhof
0e2775667d
Add category registry ()
* Add category registry

* Add entity registry support

* Update homeassistant/components/config/entity_registry.py

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

* Use ulid instead

* Add tests for adding same name in different scopes

* Handle keyerror on update

* Lookup tweak

* Omit categories from entity registry snapshots

* Use base registry

* Update snapshots

* Update snapshots

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2024-03-15 13:25:16 +01:00
Marc Mueller
19ab3d6daf
Add empty line after module docstring [helpers + other] () 2024-03-08 10:36:11 -05:00
J. Nick Koston
f3eb292c2d
Remove async_entity_ids and get_entity_ids from entity registry ()
added in  but not used yet.
2024-03-05 14:50:41 +01:00
J. Nick Koston
2c179dc5fb
Reduce some linear searches to cleanup the device registry ()
Some of the data we had to search for was already available
in a dict or underlying data structure. Make it available
instead of having to build it every time.

There are more places these can be used, but I only did
the device registry cleanup for now
2024-03-04 20:59:12 -05:00
Franck Nijhof
e0a9dcd996
Add label registry () 2024-02-19 11:59:08 +01:00
Franck Nijhof
aa8d8402b4
Cleanups in entity registry tests ()
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2024-02-17 19:07:46 +01:00
J. Nick Koston
9fef1938b4
Make get_entries_for_device_id skip disabled devices by default () 2024-02-04 23:11:56 +01:00
J. Nick Koston
c399cab427
Small speed up to checking core state () 2024-01-18 08:41:32 -10:00
Franck Nijhof
70ad5ab3e4
Update helper tests to use device & entity registry fixtures () 2023-11-10 09:32:19 +01:00
J. Nick Koston
433c022687
Save previous unique id in entity registry when it changes () 2023-10-16 21:26:19 -10:00
Erik Montnemery
47ecce4873
Allow deleting entity entries from entity_registry.async_migrate_entries ()
* Allow deleting entity entries from entity_registry.async_migrate_entries

* Explicitly return None in tests
2023-09-30 10:23:10 +02:00
Erik Montnemery
c7b4d4f361
Adjust helpers tests which create devices () 2023-08-10 19:28:16 +02:00
Erik Montnemery
8fda56d2c9
Stable entity registry id when a deleted entity is restored ()
* Stable entity_id and registry id when a deleted entity is restored

* Don't restore area_id

* Don't restore entity_id

* Address review comments
2023-06-26 15:54:35 +02:00
Erik Montnemery
4a8adae146
Teach alarm_control_panel device trigger about entity registry ids ()
* Teach alarm_control_panel device trigger about entity registry ids

* Lint code

* Address review comment
2023-06-20 08:27:31 -04:00
J. Nick Koston
9f0d3bfce8
Use ReadOnlyDict for entity registry options ()
* Use ReadOnlyDict for entity registry options

While reviewing  it was noticed this was slow at startup
https://github.com/home-assistant/core/pull/93601#issuecomment-1568958280

This is a first pass attempt to improve the performance

* fix tests
2023-05-30 20:11:39 -04:00
Erik Montnemery
e22618a555
Write protect entity options () 2023-03-28 22:56:51 +02:00
epenet
5f25b71df7
Add type hints to core tests () 2023-02-20 11:42:56 +01:00
Erik Montnemery
cc564026fa
Move EntityCategory to homeassistant.const ()
* Move EntityCategory to homeassistant.const

* Fix more imports
2023-02-09 20:15:37 +01:00
Franck Nijhof
80bf632e2d
Clean up unnecessary registry mocks from helpers () 2023-02-08 20:15:29 -05:00
epenet
c98b4e3204
Add typing to tests with single hass argument (2) ()
* Add typing to tests with single hass argument (2)

* a few more
2023-02-08 08:51:43 +01:00
epenet
4142f0d15d
Add return type to tests without arguments ()
* Add return type to tests without arguments

* Black

* Cancel fixture amends
2023-02-07 14:20:06 +01:00
Erik Montnemery
1f3da9cf1a
Add aliases to entity registry items () 2022-12-20 12:10:46 +01:00
Erik Montnemery
8e617bbc1d
Add translation_key property to entites ()
* Add translation_key attribute to entity state

* Update accuweather test

* Index entity translation keys by platform

* Store translation key in entity registry
2022-12-01 09:34:09 +01:00
Erik Montnemery
c38b1e7727
Improve check of new_entity_id in entity_registry.async_update_entity ()
* Improve check of new_entity_id in entity_registry.async_update_entity

* Fix race in rfxtrx config flow

* Make sure Event is created on time

* Rename poorly named variable

* Fix typing

* Correct typing of _handle_state_change
2022-09-28 08:43:58 +02:00
Erik Montnemery
4e32bf2ac9
Drop old migration code from entity registry () 2022-09-12 22:28:05 -04:00
Erik Montnemery
1bc8770b51
Remove area_id from entity_registry.async_get_or_create ()
* Remove area_id from entity_registry.async_get_or_create

* Adjust tests

* Fix lying comment in test
2022-09-02 13:31:05 +02:00
Erik Montnemery
cd2045b66d
Clean up user overridden device class in entity registry () 2022-09-01 11:45:19 -04:00
Erik Montnemery
4655ed995e
Fix resetting of attributes in EntityRegistry.async_get_or_create ()
* Fix resetting of attributes in EntityRegistry.async_get_or_create

* Fix typing

* Fix resetting config entry

* Improve test

* Update tests
2022-08-30 21:07:50 +02:00
Erik Montnemery
26a85c6644
Add Entity.has_entity_name attribute () 2022-06-28 09:38:05 -07:00
Erik Montnemery
4435c641de
Enforce RegistryEntryHider in entity registry () 2022-06-08 12:36:43 -07:00
Paulus Schoutsen
c8f95b7dfc
Ignore loading system entity category () 2022-05-05 14:33:37 -07:00
Dave T
70e125850c
Limit autogenerated entity_id string length () 2022-04-21 22:39:51 -07:00
Raman Gupta
3bcd921a28
Add entity registry helper to update entity platform ()
* Add entity registry helper to migrate entity to new platform

* Add additional assertion

* Add more properties to migration logic

* Change logic after thinking about erik's comments

* Require new_config_entry_id if entry.config_entry_id is not None

* Create private async_update_entity function that all update functions use

* Don't have special handling for entity ID missing in async_update_entity_platform

* fix docstring
2022-04-16 16:18:52 -04:00
Paulus Schoutsen
130ca2213f
Enforce EntityCategory enum ()
Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-03-31 15:04:33 -07:00
Paulus Schoutsen
5eb19b8a70
Enforce RegistryEntryDisabler enum ()
Co-authored-by: Franck Nijhof <git@frenck.dev>
2022-03-31 13:10:07 -07:00
Erik Montnemery
cd25769667
Rename async_resolve_entity_ids to async_validate_entity_ids () 2022-03-04 09:51:53 +01:00
Paulus Schoutsen
1bbc1f5f55
Validate in split_entity_id () 2022-02-18 16:11:17 -08:00
Erik Montnemery
d40a830b89
Remove entities when config entry is removed from device ()
* Remove entities when config entry is removed from device

* Update tests/helpers/test_entity_registry.py

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

* Don't remove entities not connected to a config entry

* Update homeassistant/helpers/entity_registry.py

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

Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2022-02-13 17:23:30 +01:00
Joakim Sørensen
7a40ae13a4
Add guard for invalid EntityCategory value () 2022-02-11 14:57:45 +01:00
Dave T
bf910229b6
Add test: warn entity_category assigned as str () 2022-01-28 21:46:57 +01:00
Erik Montnemery
a8c14835b9
Add entity options to entity registry ()
* Initial commit for entity options

* Tweak broadlink tests

* Add async_update_entity_options + test
2022-01-18 22:47:46 +01:00
Ville Skyttä
5bf67cac66
Use RegistryEntryDisabler () 2021-12-15 23:25:40 +02:00