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

Classes

class  _EventDeviceRegistryUpdatedData_CreateRemove
 
class  _EventDeviceRegistryUpdatedData_Update
 
class  ActiveDeviceRegistryItems
 
class  DeletedDeviceEntry
 
class  DeviceCollisionError
 
class  DeviceConnectionCollisionError
 
class  DeviceEntry
 
class  DeviceEntryDisabler
 
class  DeviceEntryType
 
class  DeviceIdentifierCollisionError
 
class  DeviceInfo
 
class  DeviceInfoError
 
class  DeviceRegistry
 
class  DeviceRegistryItems
 
class  DeviceRegistryStore
 

Functions

None __init__ (self)
 
None _index_entry (self, str key, _EntryTypeT entry)
 
set[tuple[str, str]] _normalize_connections (set[tuple[str, str]] connections)
 
None _unindex_entry (self, str key, _EntryTypeT|None replacement_entry=None)
 
str|None _validate_configuration_url (Any value)
 
str _validate_device_info (ConfigEntry config_entry, DeviceInfo device_info)
 
None async_cleanup (HomeAssistant hass, DeviceRegistry dev_reg, entity_registry.EntityRegistry ent_reg)
 
None async_config_entry_disabled_by_changed (DeviceRegistry registry, ConfigEntry config_entry)
 
list[DeviceEntryasync_entries_for_area (DeviceRegistry registry, str area_id)
 
list[DeviceEntryasync_entries_for_config_entry (DeviceRegistry registry, str config_entry_id)
 
list[DeviceEntryasync_entries_for_label (DeviceRegistry registry, str label_id)
 
DeviceRegistry async_get (HomeAssistant hass)
 
None async_load (HomeAssistant hass)
 
None async_setup_cleanup (HomeAssistant hass, DeviceRegistry dev_reg)
 
str format_mac (str mac)
 
_EntryTypeT|None get_entry (self, set[tuple[str, str]]|None identifiers, set[tuple[str, str]]|None connections)
 

Variables

 __all__ = all_with_deprecated_constants(globals())
 
 __dir__
 
 __getattr__ = partial(check_if_deprecated_constant, module_globals=globals())
 
 _cached_parse_url = lru_cache(maxsize=512)(URL)
 
 _DEPRECATED_DISABLED_CONFIG_ENTRY
 
 _DEPRECATED_DISABLED_INTEGRATION
 
 _DEPRECATED_DISABLED_USER = DeprecatedConstantEnum(DeviceEntryDisabler.USER, "2025.1")
 
 _LOGGER = logging.getLogger(__name__)
 
int CLEANUP_DELAY = 10
 
dictionary CONFIGURATION_URL_SCHEMES = {"http", "https", "homeassistant"}
 
string CONNECTION_BLUETOOTH = "bluetooth"
 
string CONNECTION_NETWORK_MAC = "mac"
 
string CONNECTION_UPNP = "upnp"
 
string CONNECTION_ZIGBEE = "zigbee"
 
 DEVICE_INFO_KEYS = set.union(*(itm for itm in DEVICE_INFO_TYPES.values()))
 
dictionary DEVICE_INFO_TYPES
 
 EventDeviceRegistryUpdatedData
 
dictionary LOW_PRIO_CONFIG_ENTRY_DOMAINS = {"homekit_controller", "matter", "mqtt", "upnp"}
 
int ORPHANED_DEVICE_KEEP_SECONDS = 86400 * 30
 
dictionary RUNTIME_ONLY_ATTRS = {"suggested_area"}
 
string STORAGE_KEY = "core.device_registry"
 
int STORAGE_VERSION_MAJOR = 1
 
int STORAGE_VERSION_MINOR = 8
 

Detailed Description

Provide a way to connect entities belonging to one device.

Function Documentation

◆ __init__()

None homeassistant.helpers.device_registry.__init__ (   self)
Container for device registry items, maps device id -> entry.

Maintains two additional indexes:
- (connection_type, connection identifier) -> entry
- (DOMAIN, identifier) -> entry
Initialize the container.

Definition at line 539 of file device_registry.py.

◆ _index_entry()

None homeassistant.helpers.device_registry._index_entry (   self,
str  key,
_EntryTypeT  entry 
)
private
Index an entry.

Definition at line 545 of file device_registry.py.

◆ _normalize_connections()

set[tuple[str, str]] homeassistant.helpers.device_registry._normalize_connections ( set[tuple[str, str]]  connections)
private
Normalize connections to ensure we can match mac addresses.

Definition at line 1468 of file device_registry.py.

◆ _unindex_entry()

None homeassistant.helpers.device_registry._unindex_entry (   self,
str  key,
_EntryTypeT | None   replacement_entry = None 
)
private
Unindex an entry.

Definition at line 552 of file device_registry.py.

◆ _validate_configuration_url()

str | None homeassistant.helpers.device_registry._validate_configuration_url ( Any  value)
private
Validate and convert configuration_url.

Definition at line 270 of file device_registry.py.

◆ _validate_device_info()

str homeassistant.helpers.device_registry._validate_device_info ( ConfigEntry  config_entry,
DeviceInfo  device_info 
)
private
Process a device info.

Definition at line 230 of file device_registry.py.

◆ async_cleanup()

None homeassistant.helpers.device_registry.async_cleanup ( HomeAssistant  hass,
DeviceRegistry  dev_reg,
entity_registry.EntityRegistry  ent_reg 
)
Clean up device registry.

Definition at line 1346 of file device_registry.py.

◆ async_config_entry_disabled_by_changed()

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

Disable devices in the registry that are associated with a config entry when
the config entry is disabled, enable devices in the registry that are associated
with a config entry when the config entry is enabled and the devices are marked
DeviceEntryDisabler.CONFIG_ENTRY.
Only disable a device if all associated config entries are disabled.

Definition at line 1305 of file device_registry.py.

◆ async_entries_for_area()

list[DeviceEntry] homeassistant.helpers.device_registry.async_entries_for_area ( DeviceRegistry  registry,
str  area_id 
)
Return entries that match an area.

Definition at line 1283 of file device_registry.py.

◆ async_entries_for_config_entry()

list[DeviceEntry] homeassistant.helpers.device_registry.async_entries_for_config_entry ( DeviceRegistry  registry,
str   config_entry_id 
)
Return entries that match a config entry.

Definition at line 1297 of file device_registry.py.

◆ async_entries_for_label()

list[DeviceEntry] homeassistant.helpers.device_registry.async_entries_for_label ( DeviceRegistry  registry,
str   label_id 
)
Return entries that match a label.

Definition at line 1289 of file device_registry.py.

◆ async_get()

DeviceRegistry homeassistant.helpers.device_registry.async_get ( HomeAssistant  hass)
Get device registry.

Definition at line 1271 of file device_registry.py.

◆ async_load()

None homeassistant.helpers.device_registry.async_load ( HomeAssistant  hass)
Load device registry.

Definition at line 1276 of file device_registry.py.

◆ async_setup_cleanup()

None homeassistant.helpers.device_registry.async_setup_cleanup ( HomeAssistant  hass,
DeviceRegistry  dev_reg 
)
Clean up device registry when entities removed.

Definition at line 1388 of file device_registry.py.

◆ format_mac()

str homeassistant.helpers.device_registry.format_mac ( str  mac)
Format the mac address string for entry into dev reg.

Definition at line 446 of file device_registry.py.

◆ get_entry()

_EntryTypeT | None homeassistant.helpers.device_registry.get_entry (   self,
set[tuple[str, str]] | None  identifiers,
set[tuple[str, str]] | None  connections 
)
Get entry from identifiers or connections.

Definition at line 562 of file device_registry.py.

Variable Documentation

◆ __all__

homeassistant.helpers.device_registry.__all__ = all_with_deprecated_constants(globals())
private

Definition at line 1481 of file device_registry.py.

◆ __dir__

homeassistant.helpers.device_registry.__dir__
private
Initial value:
1 = partial(
2  dir_with_deprecated_constants, module_globals_keys=[*globals().keys()]
3 )

Definition at line 1478 of file device_registry.py.

◆ __getattr__

homeassistant.helpers.device_registry.__getattr__ = partial(check_if_deprecated_constant, module_globals=globals())
private

Definition at line 1477 of file device_registry.py.

◆ _cached_parse_url

homeassistant.helpers.device_registry._cached_parse_url = lru_cache(maxsize=512)(URL)
private

Definition at line 266 of file device_registry.py.

◆ _DEPRECATED_DISABLED_CONFIG_ENTRY

homeassistant.helpers.device_registry._DEPRECATED_DISABLED_CONFIG_ENTRY
private
Initial value:
1 = DeprecatedConstantEnum(
2  DeviceEntryDisabler.CONFIG_ENTRY, "2025.1"
3 )

Definition at line 89 of file device_registry.py.

◆ _DEPRECATED_DISABLED_INTEGRATION

homeassistant.helpers.device_registry._DEPRECATED_DISABLED_INTEGRATION
private
Initial value:
1 = DeprecatedConstantEnum(
2  DeviceEntryDisabler.INTEGRATION, "2025.1"
3 )

Definition at line 92 of file device_registry.py.

◆ _DEPRECATED_DISABLED_USER

homeassistant.helpers.device_registry._DEPRECATED_DISABLED_USER = DeprecatedConstantEnum(DeviceEntryDisabler.USER, "2025.1")
private

Definition at line 95 of file device_registry.py.

◆ _LOGGER

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

Definition at line 56 of file device_registry.py.

◆ CLEANUP_DELAY

int homeassistant.helpers.device_registry.CLEANUP_DELAY = 10

Definition at line 66 of file device_registry.py.

◆ CONFIGURATION_URL_SCHEMES

dictionary homeassistant.helpers.device_registry.CONFIGURATION_URL_SCHEMES = {"http", "https", "homeassistant"}

Definition at line 77 of file device_registry.py.

◆ CONNECTION_BLUETOOTH

string homeassistant.helpers.device_registry.CONNECTION_BLUETOOTH = "bluetooth"

Definition at line 68 of file device_registry.py.

◆ CONNECTION_NETWORK_MAC

string homeassistant.helpers.device_registry.CONNECTION_NETWORK_MAC = "mac"

Definition at line 69 of file device_registry.py.

◆ CONNECTION_UPNP

string homeassistant.helpers.device_registry.CONNECTION_UPNP = "upnp"

Definition at line 70 of file device_registry.py.

◆ CONNECTION_ZIGBEE

string homeassistant.helpers.device_registry.CONNECTION_ZIGBEE = "zigbee"

Definition at line 71 of file device_registry.py.

◆ DEVICE_INFO_KEYS

homeassistant.helpers.device_registry.DEVICE_INFO_KEYS = set.union(*(itm for itm in DEVICE_INFO_TYPES.values()))

Definition at line 156 of file device_registry.py.

◆ DEVICE_INFO_TYPES

dictionary homeassistant.helpers.device_registry.DEVICE_INFO_TYPES

Definition at line 123 of file device_registry.py.

◆ EventDeviceRegistryUpdatedData

homeassistant.helpers.device_registry.EventDeviceRegistryUpdatedData

Definition at line 177 of file device_registry.py.

◆ LOW_PRIO_CONFIG_ENTRY_DOMAINS

dictionary homeassistant.helpers.device_registry.LOW_PRIO_CONFIG_ENTRY_DOMAINS = {"homekit_controller", "matter", "mqtt", "upnp"}

Definition at line 159 of file device_registry.py.

◆ ORPHANED_DEVICE_KEEP_SECONDS

int homeassistant.helpers.device_registry.ORPHANED_DEVICE_KEEP_SECONDS = 86400 * 30

Definition at line 73 of file device_registry.py.

◆ RUNTIME_ONLY_ATTRS

dictionary homeassistant.helpers.device_registry.RUNTIME_ONLY_ATTRS = {"suggested_area"}

Definition at line 75 of file device_registry.py.

◆ STORAGE_KEY

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

Definition at line 62 of file device_registry.py.

◆ STORAGE_VERSION_MAJOR

int homeassistant.helpers.device_registry.STORAGE_VERSION_MAJOR = 1

Definition at line 63 of file device_registry.py.

◆ STORAGE_VERSION_MINOR

int homeassistant.helpers.device_registry.STORAGE_VERSION_MINOR = 8

Definition at line 64 of file device_registry.py.