mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use DeviceInfo on awair (#58395)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
e529a56430
commit
f3ca61ffe0
@ -7,7 +7,12 @@ import voluptuous as vol
|
|||||||
from homeassistant.components.awair import AwairDataUpdateCoordinator, AwairResult
|
from homeassistant.components.awair import AwairDataUpdateCoordinator, AwairResult
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT
|
from homeassistant.config_entries import SOURCE_IMPORT
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_ACCESS_TOKEN
|
from homeassistant.const import (
|
||||||
|
ATTR_ATTRIBUTION,
|
||||||
|
ATTR_CONNECTIONS,
|
||||||
|
ATTR_NAME,
|
||||||
|
CONF_ACCESS_TOKEN,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr
|
from homeassistant.helpers import device_registry as dr
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
@ -211,17 +216,17 @@ class AwairSensor(CoordinatorEntity, SensorEntity):
|
|||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Device information."""
|
"""Device information."""
|
||||||
info = {
|
info = DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self._device.uuid)},
|
identifiers={(DOMAIN, self._device.uuid)},
|
||||||
"manufacturer": "Awair",
|
manufacturer="Awair",
|
||||||
"model": self._device.model,
|
model=self._device.model,
|
||||||
}
|
)
|
||||||
|
|
||||||
if self._device.name:
|
if self._device.name:
|
||||||
info["name"] = self._device.name
|
info[ATTR_NAME] = self._device.name
|
||||||
|
|
||||||
if self._device.mac_address:
|
if self._device.mac_address:
|
||||||
info["connections"] = {
|
info[ATTR_CONNECTIONS] = {
|
||||||
(dr.CONNECTION_NETWORK_MAC, self._device.mac_address)
|
(dr.CONNECTION_NETWORK_MAC, self._device.mac_address)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user