Commit graph

89 commits

Author SHA1 Message Date
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
Ville Skyttä
7db3246de4
Make config entry disabled_by an enum ()
* Make config entry disabled_by an enum

* Update homeassistant/config_entries.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2021-12-15 20:53:21 +01:00
Ville Skyttä
4107063a5a
Make entity registry disabled_by an enum () 2021-12-02 18:02:29 +01:00
Erik Montnemery
c85bb27d0d
Teach state trigger about entity registry ids ()
* Teach state trigger about entity registry ids

* Tweak

* Add tests

* Tweak tests

* Fix tests

* Resolve entity ids during config validation

* Update device_triggers

* Fix mistake

* Tweak trigger validator to ensure we don't modify the original config

* Add index from entry id to entry

* Update scaffold

* Pre-compile UUID regex

* Address review comment

* Tweak mock_registry

* Tweak

* Apply suggestion from code review
2021-12-02 14:26:45 +01:00
Ville Skyttä
9f4de8df18
Make device entry disabled by an enum () 2021-11-24 22:32:16 +01:00
Erik Montnemery
c0d2a66609
Add stable ID to entity registry entries ()
* Add UUID to entity registry entries

* Fix test
2021-11-24 09:01:35 +01:00
Erik Montnemery
49a27e12ad
Add support to entity registry for overriding device_class () 2021-11-22 08:38:06 -08:00
Erik Montnemery
0df2904b89
Improve some entity registry tests () 2021-11-22 10:24:37 +01:00
Erik Montnemery
c557da028a
Bump entity_registry store version to 1.2 ()
* Bump entity_registry store version to 1.2

* Migrate also when importing yaml

* Adjust tests

* Satisfy pylint

* Fix typing
2021-11-19 14:25:34 +01:00
Paulus Schoutsen
ee2c950716
Merge system options into pref properties ()
* Make system options future proof

* Update tests

* Add types
2021-06-01 22:34:31 +02:00
Raman Gupta
58e37435b3
Make more max lengths constants and add additional MaxLengthExceeded checks ()
* Add more MaxLengthExceeded checks

* remove some validations to reduce performance impact

* check length of generated entity ID

* dont check entity ID twice and use single context id length constant

* fix test

* add missing test
2021-05-25 19:58:01 +02:00
Ville Skyttä
77d5244577
Use device registry CONNECTION_* constants () 2021-04-30 23:58:50 +02:00
Ville Skyttä
a396619251
Use disabled_by constants ()
Co-authored-by: J. Nick Koston <nick@koston.org>
2021-04-23 09:56:42 +02:00
Erik Montnemery
b3fecb1c95
Update tests t-z to use async_get() instead of async_get_registry() () 2021-03-09 14:25:03 +01:00
Erik Montnemery
504e5b77ca
Improve behaviour when disabling or enabling config entries () 2021-03-03 10:12:37 -08:00
Erik Montnemery
5e26bda52d
Add support for disabling config entries () 2021-02-20 19:21:39 -08:00
Erik Montnemery
ed31cc363b
Wait for registries to load at startup ()
* Wait for registries to load at startup

* Don't decorate new functions with @bind_hass

* Fix typing errors in zwave_js

* Load registries in async_test_home_assistant

* Tweak

* Typo

* Tweak

* Explicitly silence mypy errors

* Fix tests

* Fix more tests

* Fix test

* Improve docstring

* Wait for registries to load
2021-02-11 17:36:19 +01:00