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

Public Member Functions

None __init__ (self, HomeAssistant hass)
 
None async_clear_area_id (self, str area_id)
 
None async_clear_config_entry (self, str config_entry_id)
 
None async_clear_label_id (self, str label_id)
 
DeviceEntry|None async_get (self, str device_id)
 
DeviceEntry|None async_get_device (self, set[tuple[str, str]]|None identifiers=None, set[tuple[str, str]]|None connections=None)
 
DeviceEntry async_get_or_create (self, *str config_entry_id, str|URL|None|UndefinedType configuration_url=UNDEFINED, set[tuple[str, str]]|None|UndefinedType connections=UNDEFINED, str|datetime|UndefinedType created_at=UNDEFINED, str|None|UndefinedType default_manufacturer=UNDEFINED, str|None|UndefinedType default_model=UNDEFINED, str|None|UndefinedType default_name=UNDEFINED, DeviceEntryDisabler|None|UndefinedType disabled_by=UNDEFINED, DeviceEntryType|None|UndefinedType entry_type=UNDEFINED, str|None|UndefinedType hw_version=UNDEFINED, set[tuple[str, str]]|None|UndefinedType identifiers=UNDEFINED, str|None|UndefinedType manufacturer=UNDEFINED, str|None|UndefinedType model=UNDEFINED, str|None|UndefinedType model_id=UNDEFINED, str|datetime|UndefinedType modified_at=UNDEFINED, str|None|UndefinedType name=UNDEFINED, str|None|UndefinedType serial_number=UNDEFINED, str|None|UndefinedType suggested_area=UNDEFINED, str|None|UndefinedType sw_version=UNDEFINED, str|None translation_key=None, Mapping[str, str]|None translation_placeholders=None, tuple[str, str]|None|UndefinedType via_device=UNDEFINED)
 
None async_load (self)
 
None async_purge_expired_orphaned_devices (self)
 
None async_remove_device (self, str device_id)
 
DeviceEntry|None async_update_device (self, str device_id, *str|UndefinedType add_config_entry_id=UNDEFINED, bool allow_collisions=False, str|None|UndefinedType area_id=UNDEFINED, str|URL|None|UndefinedType configuration_url=UNDEFINED, str|UndefinedType device_info_type=UNDEFINED, DeviceEntryDisabler|None|UndefinedType disabled_by=UNDEFINED, DeviceEntryType|None|UndefinedType entry_type=UNDEFINED, str|None|UndefinedType hw_version=UNDEFINED, set[str]|UndefinedType labels=UNDEFINED, str|None|UndefinedType manufacturer=UNDEFINED, set[tuple[str, str]]|UndefinedType merge_connections=UNDEFINED, set[tuple[str, str]]|UndefinedType merge_identifiers=UNDEFINED, str|None|UndefinedType model=UNDEFINED, str|None|UndefinedType model_id=UNDEFINED, str|None|UndefinedType name_by_user=UNDEFINED, str|None|UndefinedType name=UNDEFINED, set[tuple[str, str]]|UndefinedType new_connections=UNDEFINED, set[tuple[str, str]]|UndefinedType new_identifiers=UNDEFINED, str|UndefinedType remove_config_entry_id=UNDEFINED, str|None|UndefinedType serial_number=UNDEFINED, str|None|UndefinedType suggested_area=UNDEFINED, str|None|UndefinedType sw_version=UNDEFINED, str|None|UndefinedType via_device_id=UNDEFINED)
 

Public Attributes

 deleted_devices
 
 devices
 
 hass
 

Private Member Functions

DeletedDeviceEntry|None _async_get_deleted_device (self, set[tuple[str, str]] identifiers, set[tuple[str, str]] connections)
 
dict[str, Any] _data_to_save (self)
 
str _substitute_name_placeholders (self, str domain, str name, Mapping[str, str] translation_placeholders)
 
set[tuple[str, str]] _validate_connections (self, str device_id, set[tuple[str, str]] connections, bool allow_collisions)
 
set[tuple[str, str]] _validate_identifiers (self, str device_id, set[tuple[str, str]] identifiers, bool allow_collisions)
 

Private Attributes

 _device_data
 
 _store
 

Detailed Description

Class to hold a registry of devices.

Definition at line 641 of file device_registry.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.helpers.device_registry.DeviceRegistry.__init__ (   self,
HomeAssistant  hass 
)
Initialize the device registry.

Definition at line 648 of file device_registry.py.

Member Function Documentation

◆ _async_get_deleted_device()

DeletedDeviceEntry | None homeassistant.helpers.device_registry.DeviceRegistry._async_get_deleted_device (   self,
set[tuple[str, str]]  identifiers,
set[tuple[str, str]]  connections 
)
private
Check if device is deleted.

Definition at line 677 of file device_registry.py.

◆ _data_to_save()

dict[str, Any] homeassistant.helpers.device_registry.DeviceRegistry._data_to_save (   self)
private
Return data of device registry to store in a file.

Definition at line 1205 of file device_registry.py.

◆ _substitute_name_placeholders()

str homeassistant.helpers.device_registry.DeviceRegistry._substitute_name_placeholders (   self,
str  domain,
str  name,
Mapping[str, str]  translation_placeholders 
)
private
Substitute placeholders in entity name.

Definition at line 685 of file device_registry.py.

◆ _validate_connections()

set[tuple[str, str]] homeassistant.helpers.device_registry.DeviceRegistry._validate_connections (   self,
str  device_id,
set[tuple[str, str]]  connections,
bool  allow_collisions 
)
private
Normalize and validate connections, raise on collision with other devices.

Definition at line 1069 of file device_registry.py.

◆ _validate_identifiers()

set[tuple[str, str]] homeassistant.helpers.device_registry.DeviceRegistry._validate_identifiers (   self,
str  device_id,
set[tuple[str, str]]  identifiers,
bool  allow_collisions 
)
private
Validate identifiers, raise on collision with other devices.

Definition at line 1094 of file device_registry.py.

◆ async_clear_area_id()

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

Definition at line 1257 of file device_registry.py.

◆ async_clear_config_entry()

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

Definition at line 1215 of file device_registry.py.

◆ async_clear_label_id()

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

Definition at line 1263 of file device_registry.py.

◆ async_get()

DeviceEntry | None homeassistant.helpers.device_registry.DeviceRegistry.async_get (   self,
str  device_id 
)
Get device.

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

Definition at line 660 of file device_registry.py.

◆ async_get_device()

DeviceEntry | None homeassistant.helpers.device_registry.DeviceRegistry.async_get_device (   self,
set[tuple[str, str]] | None   identifiers = None,
set[tuple[str, str]] | None   connections = None 
)
Check if device is registered.

Definition at line 669 of file device_registry.py.

◆ async_get_or_create()

DeviceEntry homeassistant.helpers.device_registry.DeviceRegistry.async_get_or_create (   self,
*str  config_entry_id,
str | URL | None | UndefinedType   configuration_url = UNDEFINED,
set[tuple[str, str]] | None | UndefinedType   connections = UNDEFINED,
str | datetime | UndefinedType   created_at = UNDEFINED,
str | None | UndefinedType   default_manufacturer = UNDEFINED,
str | None | UndefinedType   default_model = UNDEFINED,
str | None | UndefinedType   default_name = UNDEFINED,
DeviceEntryDisabler | None | UndefinedType   disabled_by = UNDEFINED,
DeviceEntryType | None | UndefinedType   entry_type = UNDEFINED,
str | None | UndefinedType   hw_version = UNDEFINED,
set[tuple[str, str]] | None | UndefinedType   identifiers = UNDEFINED,
str | None | UndefinedType   manufacturer = UNDEFINED,
str | None | UndefinedType   model = UNDEFINED,
str | None | UndefinedType   model_id = UNDEFINED,
str | datetime | UndefinedType   modified_at = UNDEFINED,
str | None | UndefinedType   name = UNDEFINED,
str | None | UndefinedType   serial_number = UNDEFINED,
str | None | UndefinedType   suggested_area = UNDEFINED,
str | None | UndefinedType   sw_version = UNDEFINED,
str | None   translation_key = None,
Mapping[str, str] | None   translation_placeholders = None,
tuple[str, str] | None | UndefinedType   via_device = UNDEFINED 
)
Get device. Create if it doesn't exist.

Definition at line 713 of file device_registry.py.

◆ async_load()

None homeassistant.helpers.device_registry.DeviceRegistry.async_load (   self)
Load the device registry.

Definition at line 1139 of file device_registry.py.

◆ async_purge_expired_orphaned_devices()

None homeassistant.helpers.device_registry.DeviceRegistry.async_purge_expired_orphaned_devices (   self)
Purge expired orphaned devices from the registry.

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

Definition at line 1239 of file device_registry.py.

◆ async_remove_device()

None homeassistant.helpers.device_registry.DeviceRegistry.async_remove_device (   self,
str  device_id 
)
Remove a device from the device registry.

Definition at line 1116 of file device_registry.py.

◆ async_update_device()

DeviceEntry | None homeassistant.helpers.device_registry.DeviceRegistry.async_update_device (   self,
str  device_id,
*str | UndefinedType   add_config_entry_id = UNDEFINED,
bool   allow_collisions = False,
str | None | UndefinedType   area_id = UNDEFINED,
str | URL | None | UndefinedType   configuration_url = UNDEFINED,
str | UndefinedType   device_info_type = UNDEFINED,
DeviceEntryDisabler | None | UndefinedType   disabled_by = UNDEFINED,
DeviceEntryType | None | UndefinedType   entry_type = UNDEFINED,
str | None | UndefinedType   hw_version = UNDEFINED,
set[str] | UndefinedType   labels = UNDEFINED,
str | None | UndefinedType   manufacturer = UNDEFINED,
set[tuple[str, str]] | UndefinedType   merge_connections = UNDEFINED,
set[tuple[str, str]] | UndefinedType   merge_identifiers = UNDEFINED,
str | None | UndefinedType   model = UNDEFINED,
str | None | UndefinedType   model_id = UNDEFINED,
str | None | UndefinedType   name_by_user = UNDEFINED,
str | None | UndefinedType   name = UNDEFINED,
set[tuple[str, str]] | UndefinedType   new_connections = UNDEFINED,
set[tuple[str, str]] | UndefinedType   new_identifiers = UNDEFINED,
str | UndefinedType   remove_config_entry_id = UNDEFINED,
str | None | UndefinedType   serial_number = UNDEFINED,
str | None | UndefinedType   suggested_area = UNDEFINED,
str | None | UndefinedType   sw_version = UNDEFINED,
str | None | UndefinedType   via_device_id = UNDEFINED 
)
Update device attributes.

Definition at line 856 of file device_registry.py.

Member Data Documentation

◆ _device_data

homeassistant.helpers.device_registry.DeviceRegistry._device_data
private

Definition at line 1202 of file device_registry.py.

◆ _store

homeassistant.helpers.device_registry.DeviceRegistry._store
private

Definition at line 651 of file device_registry.py.

◆ deleted_devices

homeassistant.helpers.device_registry.DeviceRegistry.deleted_devices

Definition at line 1201 of file device_registry.py.

◆ devices

homeassistant.helpers.device_registry.DeviceRegistry.devices

Definition at line 1200 of file device_registry.py.

◆ hass

homeassistant.helpers.device_registry.DeviceRegistry.hass

Definition at line 650 of file device_registry.py.


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