Use DeviceInfo in asuswrt (#58399)

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/58409/head
epenet 2021-10-25 14:12:49 +02:00 committed by GitHub
parent 3c83f31dea
commit d7c41c0b05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -4,9 +4,11 @@ from __future__ import annotations
from homeassistant.components.device_tracker import SOURCE_TYPE_ROUTER
from homeassistant.components.device_tracker.config_entry import ScannerEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_DEFAULT_NAME
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import DeviceInfo
from .const import DATA_ASUSWRT, DOMAIN
from .router import AsusWrtRouter
@ -60,12 +62,12 @@ class AsusWrtDevice(ScannerEntity):
self._device = device
self._attr_unique_id = device.mac
self._attr_name = device.name or DEFAULT_DEVICE_NAME
self._attr_device_info = {
"connections": {(CONNECTION_NETWORK_MAC, device.mac)},
"default_model": "ASUSWRT Tracked device",
}
self._attr_device_info = DeviceInfo(
connections={(CONNECTION_NETWORK_MAC, device.mac)},
default_model="ASUSWRT Tracked device",
)
if device.name:
self._attr_device_info["default_name"] = device.name
self._attr_device_info[ATTR_DEFAULT_NAME] = device.name
@property
def is_connected(self):

View File

@ -354,6 +354,7 @@ ATTR_MODE: Final = "mode"
ATTR_CONFIGURATION_URL: Final = "configuration_url"
ATTR_CONNECTIONS: Final = "connections"
ATTR_DEFAULT_NAME: Final = "default_name"
ATTR_MANUFACTURER: Final = "manufacturer"
ATTR_MODEL: Final = "model"
ATTR_SUGGESTED_AREA: Final = "suggested_area"