Home Assistant Unofficial Reference 2024.12.1
homeassistant.helpers.entity_registry.EntityRegistry Class Reference
Inheritance diagram for homeassistant.helpers.entity_registry.EntityRegistry:
[legend]
Collaboration diagram for homeassistant.helpers.entity_registry.EntityRegistry:
[legend]

Public Member Functions

None __init__ (self, HomeAssistant hass)
 
None async_clear_area_id (self, str area_id)
 
None async_clear_category_id (self, str scope, str category_id)
 
None async_clear_config_entry (self, str config_entry_id)
 
None async_clear_label_id (self, str label_id)
 
list[str] async_device_ids (self)
 
None async_device_modified (self, Event[EventDeviceRegistryUpdatedData] event)
 
str async_generate_entity_id (self, str domain, str suggested_object_id, Container[str]|None known_object_ids=None)
 
RegistryEntry|None async_get (self, str entity_id_or_uuid)
 
str|None async_get_entity_id (self, str domain, str platform, str unique_id)
 
RegistryEntry async_get_or_create (self, str domain, str platform, str unique_id, *Container[str]|None known_object_ids=None, str|None suggested_object_id=None, RegistryEntryDisabler|None disabled_by=None, RegistryEntryHider|None hidden_by=None, Callable[[], EntityOptionsType|None]|None get_initial_options=None, Mapping[str, Any]|None|UndefinedType capabilities=UNDEFINED, ConfigEntry|None|UndefinedType config_entry=UNDEFINED, str|None|UndefinedType device_id=UNDEFINED, EntityCategory|UndefinedType|None entity_category=UNDEFINED, bool|UndefinedType has_entity_name=UNDEFINED, str|None|UndefinedType original_device_class=UNDEFINED, str|None|UndefinedType original_icon=UNDEFINED, str|None|UndefinedType original_name=UNDEFINED, int|None|UndefinedType supported_features=UNDEFINED, str|None|UndefinedType translation_key=UNDEFINED, str|None|UndefinedType unit_of_measurement=UNDEFINED)
 
bool async_is_registered (self, str entity_id)
 
None async_load (self)
 
None async_purge_expired_orphaned_entities (self)
 
None async_remove (self, str entity_id)
 
RegistryEntry async_update_entity (self, str entity_id, *set[str]|UndefinedType aliases=UNDEFINED, str|None|UndefinedType area_id=UNDEFINED, dict[str, str]|UndefinedType categories=UNDEFINED, Mapping[str, Any]|None|UndefinedType capabilities=UNDEFINED, str|None|UndefinedType config_entry_id=UNDEFINED, str|None|UndefinedType device_class=UNDEFINED, str|None|UndefinedType device_id=UNDEFINED, RegistryEntryDisabler|None|UndefinedType disabled_by=UNDEFINED, EntityCategory|None|UndefinedType entity_category=UNDEFINED, RegistryEntryHider|None|UndefinedType hidden_by=UNDEFINED, str|None|UndefinedType icon=UNDEFINED, bool|UndefinedType has_entity_name=UNDEFINED, set[str]|UndefinedType labels=UNDEFINED, str|None|UndefinedType name=UNDEFINED, str|UndefinedType new_entity_id=UNDEFINED, str|UndefinedType new_unique_id=UNDEFINED, str|None|UndefinedType original_device_class=UNDEFINED, str|None|UndefinedType original_icon=UNDEFINED, str|None|UndefinedType original_name=UNDEFINED, int|UndefinedType supported_features=UNDEFINED, str|None|UndefinedType translation_key=UNDEFINED, str|None|UndefinedType unit_of_measurement=UNDEFINED)
 
RegistryEntry async_update_entity_options (self, str entity_id, str domain, Mapping[str, Any]|None options)
 
RegistryEntry async_update_entity_platform (self, str entity_id, str new_platform, *str|UndefinedType new_config_entry_id=UNDEFINED, str|UndefinedType new_unique_id=UNDEFINED, str|None|UndefinedType new_device_id=UNDEFINED)
 

Public Attributes

 deleted_entities
 
 entities
 
 hass
 

Private Member Functions

RegistryEntry _async_update_entity (self, str entity_id, *set[str]|UndefinedType aliases=UNDEFINED, str|None|UndefinedType area_id=UNDEFINED, dict[str, str]|UndefinedType categories=UNDEFINED, Mapping[str, Any]|None|UndefinedType capabilities=UNDEFINED, str|None|UndefinedType config_entry_id=UNDEFINED, str|None|UndefinedType device_class=UNDEFINED, str|None|UndefinedType device_id=UNDEFINED, RegistryEntryDisabler|None|UndefinedType disabled_by=UNDEFINED, EntityCategory|None|UndefinedType entity_category=UNDEFINED, RegistryEntryHider|None|UndefinedType hidden_by=UNDEFINED, str|None|UndefinedType icon=UNDEFINED, bool|UndefinedType has_entity_name=UNDEFINED, set[str]|UndefinedType labels=UNDEFINED, str|None|UndefinedType name=UNDEFINED, str|UndefinedType new_entity_id=UNDEFINED, str|UndefinedType new_unique_id=UNDEFINED, EntityOptionsType|UndefinedType options=UNDEFINED, str|None|UndefinedType original_device_class=UNDEFINED, str|None|UndefinedType original_icon=UNDEFINED, str|None|UndefinedType original_name=UNDEFINED, str|None|UndefinedType platform=UNDEFINED, int|UndefinedType supported_features=UNDEFINED, str|None|UndefinedType translation_key=UNDEFINED, str|None|UndefinedType unit_of_measurement=UNDEFINED)
 
dict[str, Any] _data_to_save (self)
 
bool _entity_id_available (self, str entity_id, Container[str]|None known_object_ids)
 

Private Attributes

 _entities_data
 
 _store
 

Detailed Description

Class to hold a registry of entities.

Definition at line 700 of file entity_registry.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.helpers.entity_registry.EntityRegistry.__init__ (   self,
HomeAssistant  hass 
)
Initialize the registry.

Definition at line 707 of file entity_registry.py.

Member Function Documentation

◆ _async_update_entity()

RegistryEntry homeassistant.helpers.entity_registry.EntityRegistry._async_update_entity (   self,
str  entity_id,
*set[str] | UndefinedType   aliases = UNDEFINED,
str | None | UndefinedType   area_id = UNDEFINED,
dict[str, str] | UndefinedType   categories = UNDEFINED,
Mapping[str, Any] | None | UndefinedType   capabilities = UNDEFINED,
str | None | UndefinedType   config_entry_id = UNDEFINED,
str | None | UndefinedType   device_class = UNDEFINED,
str | None | UndefinedType   device_id = UNDEFINED,
RegistryEntryDisabler | None | UndefinedType   disabled_by = UNDEFINED,
EntityCategory | None | UndefinedType   entity_category = UNDEFINED,
RegistryEntryHider | None | UndefinedType   hidden_by = UNDEFINED,
str | None | UndefinedType   icon = UNDEFINED,
bool | UndefinedType   has_entity_name = UNDEFINED,
set[str] | UndefinedType   labels = UNDEFINED,
str | None | UndefinedType   name = UNDEFINED,
str | UndefinedType   new_entity_id = UNDEFINED,
str | UndefinedType   new_unique_id = UNDEFINED,
EntityOptionsType | UndefinedType   options = UNDEFINED,
str | None | UndefinedType   original_device_class = UNDEFINED,
str | None | UndefinedType   original_icon = UNDEFINED,
str | None | UndefinedType   original_name = UNDEFINED,
str | None | UndefinedType   platform = UNDEFINED,
int | UndefinedType   supported_features = UNDEFINED,
str | None | UndefinedType   translation_key = UNDEFINED,
str | None | UndefinedType   unit_of_measurement = UNDEFINED 
)
private
Private facing update properties method.

Definition at line 1024 of file entity_registry.py.

◆ _data_to_save()

dict[str, Any] homeassistant.helpers.entity_registry.EntityRegistry._data_to_save (   self)
private
Return data of entity registry to store in a file.

Definition at line 1361 of file entity_registry.py.

◆ _entity_id_available()

bool homeassistant.helpers.entity_registry.EntityRegistry._entity_id_available (   self,
str  entity_id,
Container[str] | None   known_object_ids 
)
private
Return True if the entity_id is available.

An entity_id is available if:
- It's not registered
- It's not known by the entity component adding the entity
- It's not in the state machine

Note that an entity_id which belongs to a deleted entity is considered
available.

Definition at line 750 of file entity_registry.py.

◆ async_clear_area_id()

None homeassistant.helpers.entity_registry.EntityRegistry.async_clear_area_id (   self,
str  area_id 
)
Clear area id from registry entries.

Definition at line 1422 of file entity_registry.py.

◆ async_clear_category_id()

None homeassistant.helpers.entity_registry.EntityRegistry.async_clear_category_id (   self,
str  scope,
str  category_id 
)
Clear category id from registry entries.

Definition at line 1371 of file entity_registry.py.

◆ async_clear_config_entry()

None homeassistant.helpers.entity_registry.EntityRegistry.async_clear_config_entry (   self,
str  config_entry_id 
)
Clear config entry from registry entries.

Definition at line 1388 of file entity_registry.py.

◆ async_clear_label_id()

None homeassistant.helpers.entity_registry.EntityRegistry.async_clear_label_id (   self,
str  label_id 
)
Clear label from registry entries.

Definition at line 1382 of file entity_registry.py.

◆ async_device_ids()

list[str] homeassistant.helpers.entity_registry.EntityRegistry.async_device_ids (   self)
Return known device ids.

Definition at line 746 of file entity_registry.py.

◆ async_device_modified()

None homeassistant.helpers.entity_registry.EntityRegistry.async_device_modified (   self,
Event[EventDeviceRegistryUpdatedData]   event 
)
Handle the removal or update of a device.

Remove entities from the registry that are associated to a device when
the device is removed.

Disable entities in the registry that are associated to a device when
the device is disabled.

Definition at line 957 of file entity_registry.py.

◆ async_generate_entity_id()

str homeassistant.helpers.entity_registry.EntityRegistry.async_generate_entity_id (   self,
str  domain,
str  suggested_object_id,
Container[str] | None   known_object_ids = None 
)
Generate an entity ID that does not conflict.

Conflicts checked against registered and currently existing entities.

Definition at line 773 of file entity_registry.py.

◆ async_get()

RegistryEntry | None homeassistant.helpers.entity_registry.EntityRegistry.async_get (   self,
str  entity_id_or_uuid 
)
Get EntityEntry for an entity_id or entity entry id.

We retrieve the RegistryEntry from the underlying dict to avoid
the overhead of the UserDict __getitem__.

Definition at line 728 of file entity_registry.py.

◆ async_get_entity_id()

str | None homeassistant.helpers.entity_registry.EntityRegistry.async_get_entity_id (   self,
str  domain,
str  platform,
str   unique_id 
)
Check if an entity_id is currently registered.

Definition at line 739 of file entity_registry.py.

◆ async_get_or_create()

RegistryEntry homeassistant.helpers.entity_registry.EntityRegistry.async_get_or_create (   self,
str  domain,
str  platform,
str  unique_id,
*Container[str] | None   known_object_ids = None,
str | None   suggested_object_id = None,
RegistryEntryDisabler | None   disabled_by = None,
RegistryEntryHider | None   hidden_by = None,
Callable[[], EntityOptionsType | None] | None   get_initial_options = None,
Mapping[str, Any] | None | UndefinedType   capabilities = UNDEFINED,
ConfigEntry | None | UndefinedType   config_entry = UNDEFINED,
str | None | UndefinedType   device_id = UNDEFINED,
EntityCategory | UndefinedType | None   entity_category = UNDEFINED,
bool | UndefinedType   has_entity_name = UNDEFINED,
str | None | UndefinedType   original_device_class = UNDEFINED,
str | None | UndefinedType   original_icon = UNDEFINED,
str | None | UndefinedType   original_name = UNDEFINED,
int | None | UndefinedType   supported_features = UNDEFINED,
str | None | UndefinedType   translation_key = UNDEFINED,
str | None | UndefinedType   unit_of_measurement = UNDEFINED 
)
Get entity. Create if it doesn't exist.

Definition at line 803 of file entity_registry.py.

◆ async_is_registered()

bool homeassistant.helpers.entity_registry.EntityRegistry.async_is_registered (   self,
str  entity_id 
)
Check if an entity_id is currently registered.

Definition at line 723 of file entity_registry.py.

◆ async_load()

None homeassistant.helpers.entity_registry.EntityRegistry.async_load (   self)
Load the entity registry.

Definition at line 1256 of file entity_registry.py.

◆ async_purge_expired_orphaned_entities()

None homeassistant.helpers.entity_registry.EntityRegistry.async_purge_expired_orphaned_entities (   self)
Purge expired orphaned entities from the registry.

We need to purge these periodically to avoid the database
growing without bound.

Definition at line 1406 of file entity_registry.py.

◆ async_remove()

None homeassistant.helpers.entity_registry.EntityRegistry.async_remove (   self,
str  entity_id 
)
Remove an entity from registry.

Definition at line 931 of file entity_registry.py.

◆ async_update_entity()

RegistryEntry homeassistant.helpers.entity_registry.EntityRegistry.async_update_entity (   self,
str  entity_id,
*set[str] | UndefinedType   aliases = UNDEFINED,
str | None | UndefinedType   area_id = UNDEFINED,
dict[str, str] | UndefinedType   categories = UNDEFINED,
Mapping[str, Any] | None | UndefinedType   capabilities = UNDEFINED,
str | None | UndefinedType   config_entry_id = UNDEFINED,
str | None | UndefinedType   device_class = UNDEFINED,
str | None | UndefinedType   device_id = UNDEFINED,
RegistryEntryDisabler | None | UndefinedType   disabled_by = UNDEFINED,
EntityCategory | None | UndefinedType   entity_category = UNDEFINED,
RegistryEntryHider | None | UndefinedType   hidden_by = UNDEFINED,
str | None | UndefinedType   icon = UNDEFINED,
bool | UndefinedType   has_entity_name = UNDEFINED,
set[str] | UndefinedType   labels = UNDEFINED,
str | None | UndefinedType   name = UNDEFINED,
str | UndefinedType   new_entity_id = UNDEFINED,
str | UndefinedType   new_unique_id = UNDEFINED,
str | None | UndefinedType   original_device_class = UNDEFINED,
str | None | UndefinedType   original_icon = UNDEFINED,
str | None | UndefinedType   original_name = UNDEFINED,
int | UndefinedType   supported_features = UNDEFINED,
str | None | UndefinedType   translation_key = UNDEFINED,
str | None | UndefinedType   unit_of_measurement = UNDEFINED 
)
Update properties of an entity.

Definition at line 1151 of file entity_registry.py.

◆ async_update_entity_options()

RegistryEntry homeassistant.helpers.entity_registry.EntityRegistry.async_update_entity_options (   self,
str  entity_id,
str  domain,
Mapping[str, Any] | None   options 
)
Update entity options for a domain.

If the domain options are set to None, they will be removed.

Definition at line 1241 of file entity_registry.py.

◆ async_update_entity_platform()

RegistryEntry homeassistant.helpers.entity_registry.EntityRegistry.async_update_entity_platform (   self,
str  entity_id,
str  new_platform,
*str | UndefinedType   new_config_entry_id = UNDEFINED,
str | UndefinedType   new_unique_id = UNDEFINED,
str | None | UndefinedType   new_device_id = UNDEFINED 
)
Update entity platform.

This should only be used when an entity needs to be migrated between
integrations.

Definition at line 1206 of file entity_registry.py.

Member Data Documentation

◆ _entities_data

homeassistant.helpers.entity_registry.EntityRegistry._entities_data
private

Definition at line 1358 of file entity_registry.py.

◆ _store

homeassistant.helpers.entity_registry.EntityRegistry._store
private

Definition at line 710 of file entity_registry.py.

◆ deleted_entities

homeassistant.helpers.entity_registry.EntityRegistry.deleted_entities

Definition at line 1356 of file entity_registry.py.

◆ entities

homeassistant.helpers.entity_registry.EntityRegistry.entities

Definition at line 1357 of file entity_registry.py.

◆ hass

homeassistant.helpers.entity_registry.EntityRegistry.hass

Definition at line 709 of file entity_registry.py.


The documentation for this class was generated from the following file: