mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Use DeviceInfo in xiaomi-miio (#58642)
This commit is contained in:
parent
638bd743a5
commit
335fdf96ba
@ -14,6 +14,7 @@ from homeassistant.const import (
|
|||||||
STATE_ALARM_ARMING,
|
STATE_ALARM_ARMING,
|
||||||
STATE_ALARM_DISARMED,
|
STATE_ALARM_DISARMED,
|
||||||
)
|
)
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
|
||||||
from .const import CONF_GATEWAY, DOMAIN
|
from .const import CONF_GATEWAY, DOMAIN
|
||||||
|
|
||||||
@ -65,11 +66,11 @@ class XiaomiGatewayAlarm(AlarmControlPanelEntity):
|
|||||||
return self._gateway_device_id
|
return self._gateway_device_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info of the gateway."""
|
"""Return the device info of the gateway."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self._gateway_device_id)},
|
identifiers={(DOMAIN, self._gateway_device_id)},
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
@ -7,8 +7,9 @@ import logging
|
|||||||
from construct.core import ChecksumError
|
from construct.core import ChecksumError
|
||||||
from miio import Device, DeviceException
|
from miio import Device, DeviceException
|
||||||
|
|
||||||
|
from homeassistant.const import ATTR_CONNECTIONS
|
||||||
from homeassistant.helpers import device_registry as dr
|
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 homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from .const import CONF_MAC, CONF_MODEL, DOMAIN, AuthException, SetupException
|
from .const import CONF_MAC, CONF_MODEL, DOMAIN, AuthException, SetupException
|
||||||
@ -85,17 +86,17 @@ class XiaomiMiioEntity(Entity):
|
|||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
device_info = {
|
device_info = DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self._device_id)},
|
identifiers={(DOMAIN, self._device_id)},
|
||||||
"manufacturer": "Xiaomi",
|
manufacturer="Xiaomi",
|
||||||
"name": self._name,
|
model=self._model,
|
||||||
"model": self._model,
|
name=self._name,
|
||||||
}
|
)
|
||||||
|
|
||||||
if self._mac is not None:
|
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
|
return device_info
|
||||||
|
|
||||||
@ -125,17 +126,17 @@ class XiaomiCoordinatedMiioEntity(CoordinatorEntity):
|
|||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
device_info = {
|
device_info = DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self._device_id)},
|
identifiers={(DOMAIN, self._device_id)},
|
||||||
"manufacturer": "Xiaomi",
|
manufacturer="Xiaomi",
|
||||||
"name": self._device_name,
|
model=self._model,
|
||||||
"model": self._model,
|
name=self._device_name,
|
||||||
}
|
)
|
||||||
|
|
||||||
if self._mac is not None:
|
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
|
return device_info
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ from homeassistant.components.light import (
|
|||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_ENTITY_ID, CONF_HOST, CONF_TOKEN
|
from homeassistant.const import ATTR_ENTITY_ID, CONF_HOST, CONF_TOKEN
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.util import color, dt
|
from homeassistant.util import color, dt
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -944,11 +945,11 @@ class XiaomiGatewayLight(LightEntity):
|
|||||||
return self._unique_id
|
return self._unique_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info of the gateway."""
|
"""Return the device info of the gateway."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self._gateway_device_id)},
|
identifiers={(DOMAIN, self._gateway_device_id)},
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user