From f3ca61ffe055d7b2da6199de76e036620539815a Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Mon, 25 Oct 2021 13:09:21 +0200 Subject: [PATCH] Use DeviceInfo on awair (#58395) Co-authored-by: epenet --- homeassistant/components/awair/sensor.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/awair/sensor.py b/homeassistant/components/awair/sensor.py index 80591e36f2d..1ff1b6e0efb 100644 --- a/homeassistant/components/awair/sensor.py +++ b/homeassistant/components/awair/sensor.py @@ -7,7 +7,12 @@ import voluptuous as vol from homeassistant.components.awair import AwairDataUpdateCoordinator, AwairResult from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity 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.helpers import device_registry as dr import homeassistant.helpers.config_validation as cv @@ -211,17 +216,17 @@ class AwairSensor(CoordinatorEntity, SensorEntity): @property def device_info(self) -> DeviceInfo: """Device information.""" - info = { - "identifiers": {(DOMAIN, self._device.uuid)}, - "manufacturer": "Awair", - "model": self._device.model, - } + info = DeviceInfo( + identifiers={(DOMAIN, self._device.uuid)}, + manufacturer="Awair", + model=self._device.model, + ) if self._device.name: - info["name"] = self._device.name + info[ATTR_NAME] = self._device.name if self._device.mac_address: - info["connections"] = { + info[ATTR_CONNECTIONS] = { (dr.CONNECTION_NETWORK_MAC, self._device.mac_address) }