Move DeviceInfo from entity to device registry (#98149)
* Move DeviceInfo from entity to device registry * Update integrations
This commit is contained in:
@@ -28,7 +28,6 @@ if TYPE_CHECKING:
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
||||
from . import entity_registry
|
||||
from .entity import DeviceInfo
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -65,6 +64,26 @@ DISABLED_CONFIG_ENTRY = DeviceEntryDisabler.CONFIG_ENTRY.value
|
||||
DISABLED_INTEGRATION = DeviceEntryDisabler.INTEGRATION.value
|
||||
DISABLED_USER = DeviceEntryDisabler.USER.value
|
||||
|
||||
|
||||
class DeviceInfo(TypedDict, total=False):
|
||||
"""Entity device information for device registry."""
|
||||
|
||||
configuration_url: str | URL | None
|
||||
connections: set[tuple[str, str]]
|
||||
default_manufacturer: str
|
||||
default_model: str
|
||||
default_name: str
|
||||
entry_type: DeviceEntryType | None
|
||||
identifiers: set[tuple[str, str]]
|
||||
manufacturer: str | None
|
||||
model: str | None
|
||||
name: str | None
|
||||
suggested_area: str | None
|
||||
sw_version: str | None
|
||||
hw_version: str | None
|
||||
via_device: tuple[str, str]
|
||||
|
||||
|
||||
DEVICE_INFO_TYPES = {
|
||||
# Device info is categorized by finding the first device info type which has all
|
||||
# the keys of the device info. The link device info type must be kept first
|
||||
|
||||
@@ -12,10 +12,9 @@ import logging
|
||||
import math
|
||||
import sys
|
||||
from timeit import default_timer as timer
|
||||
from typing import TYPE_CHECKING, Any, Final, Literal, TypedDict, TypeVar, final
|
||||
from typing import TYPE_CHECKING, Any, Final, Literal, TypeVar, final
|
||||
|
||||
import voluptuous as vol
|
||||
from yarl import URL
|
||||
|
||||
from homeassistant.backports.functools import cached_property
|
||||
from homeassistant.config import DATA_CUSTOMIZE
|
||||
@@ -41,7 +40,7 @@ from homeassistant.loader import bind_hass
|
||||
from homeassistant.util import dt as dt_util, ensure_unique_string, slugify
|
||||
|
||||
from . import device_registry as dr, entity_registry as er
|
||||
from .device_registry import DeviceEntryType, EventDeviceRegistryUpdatedData
|
||||
from .device_registry import DeviceInfo, EventDeviceRegistryUpdatedData
|
||||
from .event import (
|
||||
async_track_device_registry_updated_event,
|
||||
async_track_entity_registry_updated_event,
|
||||
@@ -175,25 +174,6 @@ def get_unit_of_measurement(hass: HomeAssistant, entity_id: str) -> str | None:
|
||||
return entry.unit_of_measurement
|
||||
|
||||
|
||||
class DeviceInfo(TypedDict, total=False):
|
||||
"""Entity device information for device registry."""
|
||||
|
||||
configuration_url: str | URL | None
|
||||
connections: set[tuple[str, str]]
|
||||
default_manufacturer: str
|
||||
default_model: str
|
||||
default_name: str
|
||||
entry_type: DeviceEntryType | None
|
||||
identifiers: set[tuple[str, str]]
|
||||
manufacturer: str | None
|
||||
model: str | None
|
||||
name: str | None
|
||||
suggested_area: str | None
|
||||
sw_version: str | None
|
||||
hw_version: str | None
|
||||
via_device: tuple[str, str]
|
||||
|
||||
|
||||
ENTITY_CATEGORIES_SCHEMA: Final = vol.Coerce(EntityCategory)
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from homeassistant import const
|
||||
|
||||
from .entity import DeviceInfo
|
||||
from .device_registry import DeviceInfo
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# `sensor_state_data` is a second-party library (i.e. maintained by Home Assistant
|
||||
|
||||
Reference in New Issue
Block a user