Home Assistant Unofficial Reference 2024.12.1
device.py
Go to the documentation of this file.
1 """Create device without entities."""
2 
3 from __future__ import annotations
4 
5 from homeassistant.core import HomeAssistant
6 from homeassistant.helpers import device_registry as dr
7 
8 from . import DOMAIN
9 
10 
12  hass: HomeAssistant,
13  config_entry_id: str,
14  device_name: str | None,
15  device_translation_key: str | None,
16  device_translation_placeholders: dict[str, str] | None,
17  unique_id: str,
18 ) -> dr.DeviceEntry:
19  """Create a device."""
20  device_registry = dr.async_get(hass)
21  return device_registry.async_get_or_create(
22  config_entry_id=config_entry_id,
23  identifiers={(DOMAIN, unique_id)},
24  name=device_name,
25  translation_key=device_translation_key,
26  translation_placeholders=device_translation_placeholders,
27  )
dr.DeviceEntry async_create_device(HomeAssistant hass, str config_entry_id, str|None device_name, str|None device_translation_key, dict[str, str]|None device_translation_placeholders, str unique_id)
Definition: device.py:18