Home Assistant Unofficial Reference 2024.12.1
homeassistant.helpers.entity_registry Namespace Reference

Classes

class  _EventEntityRegistryUpdatedData_CreateRemove
 
class  _EventEntityRegistryUpdatedData_Update
 
class  DeletedRegistryEntry
 
class  EntityRegistry
 
class  EntityRegistryItems
 
class  EntityRegistryStore
 
class  RegistryEntry
 
class  RegistryEntryDisabler
 
class  RegistryEntryHider
 

Functions

None _async_setup_cleanup (HomeAssistant hass, EntityRegistry registry)
 
None _async_setup_entity_restore (HomeAssistant hass, EntityRegistry registry)
 
ReadOnlyEntityOptionsType _protect_entity_options (EntityOptionsType|None data)
 
None _validate_item (HomeAssistant hass, str domain, str platform, *RegistryEntryDisabler|None|UndefinedType disabled_by=None, EntityCategory|None|UndefinedType entity_category=None, RegistryEntryHider|None|UndefinedType hidden_by=None, bool report_non_string_unique_id=True, str|Hashable|UndefinedType|Any unique_id)
 
None async_config_entry_disabled_by_changed (EntityRegistry registry, ConfigEntry config_entry)
 
list[RegistryEntryasync_entries_for_area (EntityRegistry registry, str area_id)
 
list[RegistryEntryasync_entries_for_category (EntityRegistry registry, str scope, str category_id)
 
list[RegistryEntryasync_entries_for_config_entry (EntityRegistry registry, str config_entry_id)
 
list[RegistryEntryasync_entries_for_device (EntityRegistry registry, str device_id, bool include_disabled_entities=False)
 
list[RegistryEntryasync_entries_for_label (EntityRegistry registry, str label_id)
 
EntityRegistry async_get (HomeAssistant hass)
 
None async_load (HomeAssistant hass)
 
None async_migrate_entries (HomeAssistant hass, str config_entry_id, Callable[[RegistryEntry], dict[str, Any]|None] entry_callback)
 
str|None async_resolve_entity_id (EntityRegistry registry, str entity_id_or_uuid)
 
str async_validate_entity_id (EntityRegistry registry, str entity_id_or_uuid)
 
list[str] async_validate_entity_ids (EntityRegistry registry, list[str] entity_ids_or_uuids)
 

Variables

 _LOGGER = logging.getLogger(__name__)
 
int CLEANUP_INTERVAL = 3600 * 24
 
tuple DISPLAY_DICT_OPTIONAL
 
 ENTITY_CATEGORY_INDEX_TO_VALUE = dict(enumerate(EntityCategory))
 
dictionary ENTITY_DESCRIBING_ATTRIBUTES
 
 EntityOptionsType
 
 EventEntityRegistryUpdatedData
 
int ORPHANED_ENTITY_KEEP_SECONDS = 3600 * 24 * 30
 
 ReadOnlyEntityOptionsType
 
string STORAGE_KEY = "core.entity_registry"
 
int STORAGE_VERSION_MAJOR = 1
 
int STORAGE_VERSION_MINOR = 15
 

Detailed Description

Provide a registry to track entity IDs.

The Entity Registry keeps a registry of entities. Entities are uniquely
identified by their domain, platform and a unique id provided by that platform.

The Entity Registry will persist itself 10 seconds after a new entity is
registered. Registering a new entity while a timer is in progress resets the
timer.

Function Documentation

◆ _async_setup_cleanup()

None homeassistant.helpers.entity_registry._async_setup_cleanup ( HomeAssistant  hass,
EntityRegistry  registry 
)
private
Clean up device registry when entities removed.

Definition at line 1521 of file entity_registry.py.

◆ _async_setup_entity_restore()

None homeassistant.helpers.entity_registry._async_setup_entity_restore ( HomeAssistant  hass,
EntityRegistry  registry 
)
private
Set up the entity restore mechanism.

Definition at line 1578 of file entity_registry.py.

◆ _protect_entity_options()

ReadOnlyEntityOptionsType homeassistant.helpers.entity_registry._protect_entity_options ( EntityOptionsType | None  data)
private
Protect entity options from being modified.

Definition at line 160 of file entity_registry.py.

◆ _validate_item()

None homeassistant.helpers.entity_registry._validate_item ( HomeAssistant  hass,
str  domain,
str  platform,
*RegistryEntryDisabler | None | UndefinedType   disabled_by = None,
EntityCategory | None | UndefinedType   entity_category = None,
RegistryEntryHider | None | UndefinedType   hidden_by = None,
bool   report_non_string_unique_id = True,
str | Hashable | UndefinedType | Any  unique_id 
)
private
Validate entity registry item.

Definition at line 646 of file entity_registry.py.

◆ async_config_entry_disabled_by_changed()

None homeassistant.helpers.entity_registry.async_config_entry_disabled_by_changed ( EntityRegistry  registry,
ConfigEntry   config_entry 
)
Handle a config entry being disabled or enabled.

Disable entities in the registry that are associated with a config entry when
the config entry is disabled, enable entities in the registry that are associated
with a config entry when the config entry is enabled and the entities are marked
DISABLED_CONFIG_ENTRY.

Definition at line 1491 of file entity_registry.py.

◆ async_entries_for_area()

list[RegistryEntry] homeassistant.helpers.entity_registry.async_entries_for_area ( EntityRegistry  registry,
str   area_id 
)
Return entries that match an area.

Definition at line 1452 of file entity_registry.py.

◆ async_entries_for_category()

list[RegistryEntry] homeassistant.helpers.entity_registry.async_entries_for_category ( EntityRegistry  registry,
str  scope,
str   category_id 
)
Return entries that match a category in a scope.

Definition at line 1468 of file entity_registry.py.

◆ async_entries_for_config_entry()

list[RegistryEntry] homeassistant.helpers.entity_registry.async_entries_for_config_entry ( EntityRegistry  registry,
str   config_entry_id 
)
Return entries that match a config entry.

Definition at line 1483 of file entity_registry.py.

◆ async_entries_for_device()

list[RegistryEntry] homeassistant.helpers.entity_registry.async_entries_for_device ( EntityRegistry  registry,
str  device_id,
bool   include_disabled_entities = False 
)
Return entries that match a device.

Definition at line 1442 of file entity_registry.py.

◆ async_entries_for_label()

list[RegistryEntry] homeassistant.helpers.entity_registry.async_entries_for_label ( EntityRegistry  registry,
str   label_id 
)
Return entries that match a label.

Definition at line 1460 of file entity_registry.py.

◆ async_get()

EntityRegistry homeassistant.helpers.entity_registry.async_get ( HomeAssistant  hass)
Get entity registry.

Definition at line 1430 of file entity_registry.py.

◆ async_load()

None homeassistant.helpers.entity_registry.async_load ( HomeAssistant  hass)
Load entity registry.

Definition at line 1435 of file entity_registry.py.

◆ async_migrate_entries()

None homeassistant.helpers.entity_registry.async_migrate_entries ( HomeAssistant  hass,
str  config_entry_id,
Callable[[RegistryEntry], dict[str, Any] | None]  entry_callback 
)
Migrate entity registry entries which belong to a config entry.

Can be used as a migrator of unique_ids or to update other entity registry data.
Can also be used to remove duplicated entity registry entries.

Definition at line 1619 of file entity_registry.py.

◆ async_resolve_entity_id()

str | None homeassistant.helpers.entity_registry.async_resolve_entity_id ( EntityRegistry  registry,
str   entity_id_or_uuid 
)
Validate and resolve an entity id or UUID to an entity id.

Returns None if the entity or UUID is invalid, or if the UUID is not
associated with an entity registry item.

Definition at line 1654 of file entity_registry.py.

◆ async_validate_entity_id()

str homeassistant.helpers.entity_registry.async_validate_entity_id ( EntityRegistry  registry,
str  entity_id_or_uuid 
)
Validate and resolve an entity id or UUID to an entity id.

Raises vol.Invalid if the entity or UUID is invalid, or if the UUID is not
associated with an entity registry item.

Definition at line 1640 of file entity_registry.py.

◆ async_validate_entity_ids()

list[str] homeassistant.helpers.entity_registry.async_validate_entity_ids ( EntityRegistry  registry,
list[str]   entity_ids_or_uuids 
)
Validate and resolve a list of entity ids or UUIDs to a list of entity ids.

Returns a list with UUID resolved to entity_ids.
Raises vol.Invalid if any item is invalid, or if any a UUID is not associated with
an entity registry item.

Definition at line 1670 of file entity_registry.py.

Variable Documentation

◆ _LOGGER

homeassistant.helpers.entity_registry._LOGGER = logging.getLogger(__name__)
private

Definition at line 79 of file entity_registry.py.

◆ CLEANUP_INTERVAL

int homeassistant.helpers.entity_registry.CLEANUP_INTERVAL = 3600 * 24

Definition at line 85 of file entity_registry.py.

◆ DISPLAY_DICT_OPTIONAL

tuple homeassistant.helpers.entity_registry.DISPLAY_DICT_OPTIONAL
Initial value:
1 = (
2  # key, attr_name, convert_to_list
3  ("ai", "area_id", False),
4  ("lb", "labels", True),
5  ("di", "device_id", False),
6  ("ic", "icon", False),
7  ("tk", "translation_key", False),
8 )

Definition at line 150 of file entity_registry.py.

◆ ENTITY_CATEGORY_INDEX_TO_VALUE

homeassistant.helpers.entity_registry.ENTITY_CATEGORY_INDEX_TO_VALUE = dict(enumerate(EntityCategory))

Definition at line 93 of file entity_registry.py.

◆ ENTITY_DESCRIBING_ATTRIBUTES

dictionary homeassistant.helpers.entity_registry.ENTITY_DESCRIBING_ATTRIBUTES
Initial value:
1 = {
2  "capabilities",
3  "device_class",
4  "entity_id",
5  "name",
6  "original_name",
7  "supported_features",
8  "unit_of_measurement",
9 }

Definition at line 97 of file entity_registry.py.

◆ EntityOptionsType

homeassistant.helpers.entity_registry.EntityOptionsType

Definition at line 147 of file entity_registry.py.

◆ EventEntityRegistryUpdatedData

homeassistant.helpers.entity_registry.EventEntityRegistryUpdatedData

Definition at line 141 of file entity_registry.py.

◆ ORPHANED_ENTITY_KEEP_SECONDS

int homeassistant.helpers.entity_registry.ORPHANED_ENTITY_KEEP_SECONDS = 3600 * 24 * 30

Definition at line 86 of file entity_registry.py.

◆ ReadOnlyEntityOptionsType

homeassistant.helpers.entity_registry.ReadOnlyEntityOptionsType

Definition at line 148 of file entity_registry.py.

◆ STORAGE_KEY

string homeassistant.helpers.entity_registry.STORAGE_KEY = "core.entity_registry"

Definition at line 83 of file entity_registry.py.

◆ STORAGE_VERSION_MAJOR

int homeassistant.helpers.entity_registry.STORAGE_VERSION_MAJOR = 1

Definition at line 81 of file entity_registry.py.

◆ STORAGE_VERSION_MINOR

int homeassistant.helpers.entity_registry.STORAGE_VERSION_MINOR = 15

Definition at line 82 of file entity_registry.py.