Use DeviceInfo in xiaomi-miio (#58642)
This commit is contained in:
parent
638bd743a5
commit
335fdf96ba
3 changed files with 28 additions and 25 deletions
|
@ -14,6 +14,7 @@ from homeassistant.const import (
|
|||
STATE_ALARM_ARMING,
|
||||
STATE_ALARM_DISARMED,
|
||||
)
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from .const import CONF_GATEWAY, DOMAIN
|
||||
|
||||
|
@ -65,11 +66,11 @@ class XiaomiGatewayAlarm(AlarmControlPanelEntity):
|
|||
return self._gateway_device_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info of the gateway."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._gateway_device_id)},
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._gateway_device_id)},
|
||||
)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
|
@ -7,8 +7,9 @@ import logging
|
|||
from construct.core import ChecksumError
|
||||
from miio import Device, DeviceException
|
||||
|
||||
from homeassistant.const import ATTR_CONNECTIONS
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import CONF_MAC, CONF_MODEL, DOMAIN, AuthException, SetupException
|
||||
|
@ -85,17 +86,17 @@ class XiaomiMiioEntity(Entity):
|
|||
return self._name
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
device_info = {
|
||||
"identifiers": {(DOMAIN, self._device_id)},
|
||||
"manufacturer": "Xiaomi",
|
||||
"name": self._name,
|
||||
"model": self._model,
|
||||
}
|
||||
device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self._device_id)},
|
||||
manufacturer="Xiaomi",
|
||||
model=self._model,
|
||||
name=self._name,
|
||||
)
|
||||
|
||||
if self._mac is not None:
|
||||
device_info["connections"] = {(dr.CONNECTION_NETWORK_MAC, self._mac)}
|
||||
device_info[ATTR_CONNECTIONS] = {(dr.CONNECTION_NETWORK_MAC, self._mac)}
|
||||
|
||||
return device_info
|
||||
|
||||
|
@ -125,17 +126,17 @@ class XiaomiCoordinatedMiioEntity(CoordinatorEntity):
|
|||
return self._name
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
device_info = {
|
||||
"identifiers": {(DOMAIN, self._device_id)},
|
||||
"manufacturer": "Xiaomi",
|
||||
"name": self._device_name,
|
||||
"model": self._model,
|
||||
}
|
||||
device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self._device_id)},
|
||||
manufacturer="Xiaomi",
|
||||
model=self._model,
|
||||
name=self._device_name,
|
||||
)
|
||||
|
||||
if self._mac is not None:
|
||||
device_info["connections"] = {(dr.CONNECTION_NETWORK_MAC, self._mac)}
|
||||
device_info[ATTR_CONNECTIONS] = {(dr.CONNECTION_NETWORK_MAC, self._mac)}
|
||||
|
||||
return device_info
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ from homeassistant.components.light import (
|
|||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, CONF_HOST, CONF_TOKEN
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.util import color, dt
|
||||
|
||||
from .const import (
|
||||
|
@ -944,11 +945,11 @@ class XiaomiGatewayLight(LightEntity):
|
|||
return self._unique_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info of the gateway."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._gateway_device_id)},
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._gateway_device_id)},
|
||||
)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue