Adapt asuswrt to new device registry API (#176936)

This commit is contained in:
Erik Montnemery
2026-07-21 08:31:17 +02:00
committed by GitHub
parent cecee55659
commit 94334d854d
2 changed files with 10 additions and 3 deletions
@@ -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
+7 -1
View File
@@ -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,