mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Adapt asuswrt to new device registry API (#176936)
This commit is contained in:
@@ -18,6 +18,7 @@ from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
from . import AsusWrtConfigEntry
|
||||
from .router import get_device_identifier
|
||||
|
||||
TO_REDACT = {CONF_PASSWORD, CONF_UNIQUE_ID, CONF_USERNAME}
|
||||
TO_REDACT_DEV = {ATTR_CONNECTIONS, ATTR_IDENTIFIERS}
|
||||
@@ -34,8 +35,8 @@ async def async_get_config_entry_diagnostics(
|
||||
# Gather information how this AsusWrt device is represented in Home Assistant
|
||||
device_registry = dr.async_get(hass)
|
||||
entity_registry = er.async_get(hass)
|
||||
hass_device = device_registry.async_get_device(
|
||||
identifiers=router.device_info[ATTR_IDENTIFIERS]
|
||||
hass_device = device_registry.async_get_device_by_identifier(
|
||||
get_device_identifier(entry), entry.entry_id
|
||||
)
|
||||
if not hass_device:
|
||||
return data
|
||||
|
||||
@@ -53,6 +53,12 @@ SENSORS_TYPE_COUNT = "sensors_count"
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_device_identifier(entry: ConfigEntry) -> tuple[str, str]:
|
||||
"""Return the device registry identifier of the router."""
|
||||
return (DOMAIN, entry.unique_id or "AsusWRT")
|
||||
|
||||
|
||||
_ENTITY_MIGRATION_ID = {
|
||||
"sensor_connected_device": "Devices Connected",
|
||||
"sensor_rx_bytes": "Download",
|
||||
@@ -389,7 +395,7 @@ class AsusWrtRouter:
|
||||
"""Return the device information."""
|
||||
info = DeviceInfo(
|
||||
configuration_url=self._api.configuration_url,
|
||||
identifiers={(DOMAIN, self._entry.unique_id or "AsusWRT")},
|
||||
identifiers={get_device_identifier(self._entry)},
|
||||
name=self.host,
|
||||
model=self._api.model or "Asus Router",
|
||||
model_id=self._api.model_id,
|
||||
|
||||
Reference in New Issue
Block a user