Use DeviceInfo class - A (#57859)

This commit is contained in:
Robert Hillis 2021-10-22 10:35:39 -04:00 committed by GitHub
parent 8bc1509afa
commit 59fe30e589
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 140 additions and 151 deletions

View file

@ -7,8 +7,8 @@ from homeassistant.components.sensor import (
SensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_IDENTIFIERS, ATTR_MANUFACTURER, ATTR_NAME
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import (
@ -16,7 +16,7 @@ from homeassistant.helpers.update_coordinator import (
DataUpdateCoordinator,
)
from .const import ATTR_ENTRY_TYPE, DOMAIN, ENTRY_TYPE_SERVICE, SENSORS, SERVICES
from .const import DOMAIN, ENTRY_TYPE_SERVICE, SENSORS, SERVICES
async def async_setup_entry(
@ -58,12 +58,12 @@ class AmbeeSensorEntity(CoordinatorEntity, SensorEntity):
self.entity_description = description
self._attr_unique_id = f"{entry_id}_{service_key}_{description.key}"
self._attr_device_info = {
ATTR_IDENTIFIERS: {(DOMAIN, f"{entry_id}_{service_key}")},
ATTR_NAME: service,
ATTR_MANUFACTURER: "Ambee",
ATTR_ENTRY_TYPE: ENTRY_TYPE_SERVICE,
}
self._attr_device_info = DeviceInfo(
entry_type=ENTRY_TYPE_SERVICE,
identifiers={(DOMAIN, f"{entry_id}_{service_key}")},
manufacturer="Ambee",
name=service,
)
@property
def native_value(self) -> StateType: