Use DeviceInfo in asuswrt (#58399)
Co-authored-by: epenet <epenet@users.noreply.github.com>pull/58409/head
parent
3c83f31dea
commit
d7c41c0b05
|
@ -4,9 +4,11 @@ from __future__ import annotations
|
||||||
from homeassistant.components.device_tracker import SOURCE_TYPE_ROUTER
|
from homeassistant.components.device_tracker import SOURCE_TYPE_ROUTER
|
||||||
from homeassistant.components.device_tracker.config_entry import ScannerEntity
|
from homeassistant.components.device_tracker.config_entry import ScannerEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
from homeassistant.const import ATTR_DEFAULT_NAME
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
|
||||||
from .const import DATA_ASUSWRT, DOMAIN
|
from .const import DATA_ASUSWRT, DOMAIN
|
||||||
from .router import AsusWrtRouter
|
from .router import AsusWrtRouter
|
||||||
|
@ -60,12 +62,12 @@ class AsusWrtDevice(ScannerEntity):
|
||||||
self._device = device
|
self._device = device
|
||||||
self._attr_unique_id = device.mac
|
self._attr_unique_id = device.mac
|
||||||
self._attr_name = device.name or DEFAULT_DEVICE_NAME
|
self._attr_name = device.name or DEFAULT_DEVICE_NAME
|
||||||
self._attr_device_info = {
|
self._attr_device_info = DeviceInfo(
|
||||||
"connections": {(CONNECTION_NETWORK_MAC, device.mac)},
|
connections={(CONNECTION_NETWORK_MAC, device.mac)},
|
||||||
"default_model": "ASUSWRT Tracked device",
|
default_model="ASUSWRT Tracked device",
|
||||||
}
|
)
|
||||||
if device.name:
|
if device.name:
|
||||||
self._attr_device_info["default_name"] = device.name
|
self._attr_device_info[ATTR_DEFAULT_NAME] = device.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_connected(self):
|
def is_connected(self):
|
||||||
|
|
|
@ -354,6 +354,7 @@ ATTR_MODE: Final = "mode"
|
||||||
|
|
||||||
ATTR_CONFIGURATION_URL: Final = "configuration_url"
|
ATTR_CONFIGURATION_URL: Final = "configuration_url"
|
||||||
ATTR_CONNECTIONS: Final = "connections"
|
ATTR_CONNECTIONS: Final = "connections"
|
||||||
|
ATTR_DEFAULT_NAME: Final = "default_name"
|
||||||
ATTR_MANUFACTURER: Final = "manufacturer"
|
ATTR_MANUFACTURER: Final = "manufacturer"
|
||||||
ATTR_MODEL: Final = "model"
|
ATTR_MODEL: Final = "model"
|
||||||
ATTR_SUGGESTED_AREA: Final = "suggested_area"
|
ATTR_SUGGESTED_AREA: Final = "suggested_area"
|
||||||
|
|
Loading…
Reference in New Issue