Use DeviceInfo class - A (#57859)
This commit is contained in:
parent
8bc1509afa
commit
59fe30e589
22 changed files with 140 additions and 151 deletions
|
@ -20,7 +20,7 @@ from homeassistant.const import (
|
|||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import dispatcher_send
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
|
||||
from .const import ATTRIBUTION, DEFAULT_CACHEDB, DOMAIN, LOGGER
|
||||
|
||||
|
@ -322,14 +322,14 @@ class AbodeDevice(AbodeEntity):
|
|||
}
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device registry information for this entity."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._device.device_id)},
|
||||
"manufacturer": "Abode",
|
||||
"name": self._device.name,
|
||||
"device_type": self._device.type,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._device.device_id)},
|
||||
manufacturer="Abode",
|
||||
model=self._device.type,
|
||||
name=self._device.name,
|
||||
)
|
||||
|
||||
def _update_callback(self, device):
|
||||
"""Update the device state."""
|
||||
|
|
|
@ -7,6 +7,7 @@ from homeassistant.components.sensor import SensorEntity
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_NAME, DEVICE_CLASS_TEMPERATURE
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
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 CoordinatorEntity
|
||||
|
@ -93,12 +94,12 @@ class AccuWeatherSensor(CoordinatorEntity, SensorEntity):
|
|||
else:
|
||||
self._unit_system = API_IMPERIAL
|
||||
self._attr_native_unit_of_measurement = description.unit_imperial
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(DOMAIN, coordinator.location_key)},
|
||||
"name": NAME,
|
||||
"manufacturer": MANUFACTURER,
|
||||
"entry_type": "service",
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
entry_type="service",
|
||||
identifiers={(DOMAIN, coordinator.location_key)},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=NAME,
|
||||
)
|
||||
self.forecast_day = forecast_day
|
||||
|
||||
@property
|
||||
|
|
|
@ -81,7 +81,7 @@ class AcmedaBase(entity.Entity):
|
|||
"""Return the device info."""
|
||||
return entity.DeviceInfo(
|
||||
identifiers={(DOMAIN, self.unique_id)},
|
||||
name=self.roller.name,
|
||||
manufacturer="Rollease Acmeda",
|
||||
name=self.roller.name,
|
||||
via_device=(DOMAIN, self.roller.hub.id),
|
||||
)
|
||||
|
|
|
@ -196,14 +196,14 @@ class AdGuardHomeDeviceEntity(AdGuardHomeEntity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information about this AdGuard Home instance."""
|
||||
return {
|
||||
"identifiers": {
|
||||
return DeviceInfo(
|
||||
entry_type="service",
|
||||
identifiers={
|
||||
(DOMAIN, self.adguard.host, self.adguard.port, self.adguard.base_path) # type: ignore
|
||||
},
|
||||
"name": "AdGuard Home",
|
||||
"manufacturer": "AdGuard Team",
|
||||
"sw_version": self.hass.data[DOMAIN][self._entry.entry_id].get(
|
||||
manufacturer="AdGuard Team",
|
||||
name="AdGuard Home",
|
||||
sw_version=self.hass.data[DOMAIN][self._entry.entry_id].get(
|
||||
DATA_ADGUARD_VERSION
|
||||
),
|
||||
"entry_type": "service",
|
||||
}
|
||||
)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""Advantage Air parent entity class."""
|
||||
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -14,13 +15,13 @@ class AdvantageAirEntity(CoordinatorEntity):
|
|||
self.async_change = instance["async_change"]
|
||||
self.ac_key = ac_key
|
||||
self.zone_key = zone_key
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(DOMAIN, self.coordinator.data["system"]["rid"])},
|
||||
"name": self.coordinator.data["system"]["name"],
|
||||
"manufacturer": "Advantage Air",
|
||||
"model": self.coordinator.data["system"]["sysType"],
|
||||
"sw_version": self.coordinator.data["system"]["myAppRev"],
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self.coordinator.data["system"]["rid"])},
|
||||
manufacturer="Advantage Air",
|
||||
model=self.coordinator.data["system"]["sysType"],
|
||||
name=self.coordinator.data["system"]["name"],
|
||||
sw_version=self.coordinator.data["system"]["myAppRev"],
|
||||
)
|
||||
|
||||
@property
|
||||
def _ac(self):
|
||||
|
|
|
@ -11,6 +11,7 @@ from homeassistant.const import (
|
|||
STATE_ALARM_ARMED_NIGHT,
|
||||
STATE_ALARM_DISARMED,
|
||||
)
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from .const import CONNECTION, DOMAIN as AGENT_DOMAIN
|
||||
|
||||
|
@ -45,12 +46,12 @@ class AgentBaseStation(AlarmControlPanelEntity):
|
|||
self._client = client
|
||||
self._attr_name = f"{client.name} {CONST_ALARM_CONTROL_PANEL_NAME}"
|
||||
self._attr_unique_id = f"{client.unique}_CP"
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(AGENT_DOMAIN, client.unique)},
|
||||
"manufacturer": "Agent",
|
||||
"model": CONST_ALARM_CONTROL_PANEL_NAME,
|
||||
"sw_version": client.version,
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(AGENT_DOMAIN, client.unique)},
|
||||
manufacturer="Agent",
|
||||
model=CONST_ALARM_CONTROL_PANEL_NAME,
|
||||
sw_version=client.version,
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
"""Update the state of the device."""
|
||||
|
|
|
@ -13,6 +13,7 @@ from homeassistant.components.mjpeg.camera import (
|
|||
)
|
||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME
|
||||
from homeassistant.helpers import entity_platform
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from .const import (
|
||||
ATTRIBUTION,
|
||||
|
@ -79,13 +80,13 @@ class AgentCamera(MjpegCamera):
|
|||
self._attr_name = f"{device.client.name} {device.name}"
|
||||
self._attr_unique_id = f"{device._client.unique}_{device.typeID}_{device.id}"
|
||||
super().__init__(device_info)
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(AGENT_DOMAIN, self.unique_id)},
|
||||
"name": self.name,
|
||||
"manufacturer": "Agent",
|
||||
"model": "Camera",
|
||||
"sw_version": device.client.version,
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(AGENT_DOMAIN, self.unique_id)},
|
||||
manufacturer="Agent",
|
||||
model="Camera",
|
||||
name=self.name,
|
||||
sw_version=device.client.version,
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
"""Update our state from the Agent API."""
|
||||
|
|
|
@ -27,6 +27,7 @@ from homeassistant.const import (
|
|||
TEMP_CELSIUS,
|
||||
)
|
||||
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 CoordinatorEntity
|
||||
|
@ -151,14 +152,12 @@ class AirlySensor(CoordinatorEntity, SensorEntity):
|
|||
) -> None:
|
||||
"""Initialize."""
|
||||
super().__init__(coordinator)
|
||||
self._attr_device_info = {
|
||||
"identifiers": {
|
||||
(DOMAIN, f"{coordinator.latitude}-{coordinator.longitude}")
|
||||
},
|
||||
"name": DEFAULT_NAME,
|
||||
"manufacturer": MANUFACTURER,
|
||||
"entry_type": "service",
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
entry_type="service",
|
||||
identifiers={(DOMAIN, f"{coordinator.latitude}-{coordinator.longitude}")},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=DEFAULT_NAME,
|
||||
)
|
||||
self._attr_name = f"{name} {description.name}"
|
||||
self._attr_unique_id = (
|
||||
f"{coordinator.latitude}-{coordinator.longitude}-{description.key}".lower()
|
||||
|
|
|
@ -21,6 +21,7 @@ from homeassistant.components.climate.const import (
|
|||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -96,14 +97,14 @@ class AirtouchAC(CoordinatorEntity, ClimateEntity):
|
|||
return super()._handle_coordinator_update()
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info for this device."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self.unique_id)},
|
||||
"name": self.name,
|
||||
"manufacturer": "Airtouch",
|
||||
"model": "Airtouch 4",
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.unique_id)},
|
||||
name=self.name,
|
||||
manufacturer="Airtouch",
|
||||
model="Airtouch 4",
|
||||
)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
@ -211,14 +212,14 @@ class AirtouchGroup(CoordinatorEntity, ClimateEntity):
|
|||
return super()._handle_coordinator_update()
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info for this device."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self.unique_id)},
|
||||
"name": self.name,
|
||||
"manufacturer": "Airtouch",
|
||||
"model": "Airtouch 4",
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.unique_id)},
|
||||
manufacturer="Airtouch",
|
||||
model="Airtouch 4",
|
||||
name=self.name,
|
||||
)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
|
|
@ -319,16 +319,16 @@ class AirVisualNodeProSensor(AirVisualEntity, SensorEntity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device registry information for this entity."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self.coordinator.data["serial_number"])},
|
||||
"name": self.coordinator.data["settings"]["node_name"],
|
||||
"manufacturer": "AirVisual",
|
||||
"model": f'{self.coordinator.data["status"]["model"]}',
|
||||
"sw_version": (
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.coordinator.data["serial_number"])},
|
||||
manufacturer="AirVisual",
|
||||
model=f'{self.coordinator.data["status"]["model"]}',
|
||||
name=self.coordinator.data["settings"]["node_name"],
|
||||
sw_version=(
|
||||
f'Version {self.coordinator.data["status"]["system_version"]}'
|
||||
f'{self.coordinator.data["status"]["app_version"]}'
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
@callback
|
||||
def update_from_latest_data(self) -> None:
|
||||
|
|
|
@ -21,7 +21,6 @@ DOMAIN: Final = "ambee"
|
|||
LOGGER = logging.getLogger(__package__)
|
||||
SCAN_INTERVAL = timedelta(hours=1)
|
||||
|
||||
ATTR_ENTRY_TYPE: Final = "entry_type"
|
||||
ENTRY_TYPE_SERVICE: Final = "service"
|
||||
|
||||
DEVICE_CLASS_AMBEE_RISK: Final = "ambee__risk"
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -21,6 +21,7 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from .const import (
|
||||
ATTR_VALUE,
|
||||
|
@ -149,11 +150,11 @@ class AmbiclimateEntity(ClimateEntity):
|
|||
self._store = store
|
||||
self._attr_unique_id = heater.device_id
|
||||
self._attr_name = heater.name
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(DOMAIN, self.unique_id)},
|
||||
"name": self.name,
|
||||
"manufacturer": "Ambiclimate",
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self.unique_id)},
|
||||
manufacturer="Ambiclimate",
|
||||
name=self.name,
|
||||
)
|
||||
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
|
|
|
@ -20,7 +20,7 @@ from homeassistant.helpers.dispatcher import (
|
|||
async_dispatcher_connect,
|
||||
async_dispatcher_send,
|
||||
)
|
||||
from homeassistant.helpers.entity import Entity, EntityDescription
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity, EntityDescription
|
||||
from homeassistant.helpers.event import async_call_later
|
||||
|
||||
from .const import (
|
||||
|
@ -223,11 +223,11 @@ class AmbientWeatherEntity(Entity):
|
|||
) -> None:
|
||||
"""Initialize the entity."""
|
||||
self._ambient = ambient
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(DOMAIN, mac_address)},
|
||||
"name": station_name,
|
||||
"manufacturer": "Ambient Weather",
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, mac_address)},
|
||||
manufacturer="Ambient Weather",
|
||||
name=station_name,
|
||||
)
|
||||
self._attr_name = f"{station_name}_{description.name}"
|
||||
self._attr_unique_id = f"{mac_address}_{description.key}"
|
||||
self._mac_address = mac_address
|
||||
|
|
|
@ -22,7 +22,7 @@ from homeassistant.helpers.dispatcher import (
|
|||
async_dispatcher_connect,
|
||||
async_dispatcher_send,
|
||||
)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
|
||||
from .const import CONF_CREDENTIALS, CONF_IDENTIFIER, CONF_START_OFF, DOMAIN
|
||||
|
||||
|
@ -91,9 +91,7 @@ class AppleTVEntity(Entity):
|
|||
self.manager = manager
|
||||
self._attr_name = name
|
||||
self._attr_unique_id = identifier
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(DOMAIN, identifier)},
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(identifiers={(DOMAIN, identifier)})
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Handle when an entity is about to be added to Home Assistant."""
|
||||
|
|
|
@ -23,6 +23,7 @@ from homeassistant.components.media_player.const import (
|
|||
from homeassistant.components.media_player.errors import BrowseError
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from .config_flow import get_entry_client
|
||||
from .const import (
|
||||
|
@ -114,15 +115,15 @@ class ArcamFmj(MediaPlayerEntity):
|
|||
@property
|
||||
def device_info(self):
|
||||
"""Return a device description for device registry."""
|
||||
return {
|
||||
"name": self._device_name,
|
||||
"identifiers": {
|
||||
return DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, self._uuid),
|
||||
(DOMAIN, self._state.client.host, self._state.client.port),
|
||||
},
|
||||
"model": "Arcam FMJ AVR",
|
||||
"manufacturer": "Arcam",
|
||||
}
|
||||
manufacturer="Arcam",
|
||||
model="Arcam FMJ AVR",
|
||||
name=self._device_name,
|
||||
)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Once registered, add listener for events."""
|
||||
|
|
|
@ -81,10 +81,10 @@ class AtagEntity(CoordinatorEntity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return info for device registry."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self.coordinator.data.id)},
|
||||
"name": "Atag Thermostat",
|
||||
"model": "Atag One",
|
||||
"sw_version": self.coordinator.data.apiversion,
|
||||
"manufacturer": "Atag",
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.coordinator.data.id)},
|
||||
manufacturer="Atag",
|
||||
model="Atag One",
|
||||
name="Atag Thermostat",
|
||||
sw_version=self.coordinator.data.apiversion,
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Base class for August entity."""
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
|
||||
from . import DOMAIN
|
||||
from .const import MANUFACTURER
|
||||
|
@ -18,14 +18,14 @@ class AugustEntityMixin(Entity):
|
|||
super().__init__()
|
||||
self._data = data
|
||||
self._device = device
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(DOMAIN, self._device_id)},
|
||||
"name": device.device_name,
|
||||
"manufacturer": MANUFACTURER,
|
||||
"sw_version": self._detail.firmware_version,
|
||||
"model": self._detail.model,
|
||||
"suggested_area": _remove_device_types(device.device_name, DEVICE_TYPES),
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self._device_id)},
|
||||
manufacturer=MANUFACTURER,
|
||||
model=self._detail.model,
|
||||
name=device.device_name,
|
||||
sw_version=self._detail.firmware_version,
|
||||
suggested_area=_remove_device_types(device.device_name, DEVICE_TYPES),
|
||||
)
|
||||
|
||||
@property
|
||||
def _device_id(self):
|
||||
|
|
|
@ -7,17 +7,10 @@ from aiohttp import ClientError
|
|||
from auroranoaa import AuroraForecast
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_IDENTIFIERS,
|
||||
ATTR_MANUFACTURER,
|
||||
ATTR_MODEL,
|
||||
ATTR_NAME,
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
CONF_NAME,
|
||||
)
|
||||
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
|
@ -25,7 +18,6 @@ from homeassistant.helpers.update_coordinator import (
|
|||
)
|
||||
|
||||
from .const import (
|
||||
ATTR_ENTRY_TYPE,
|
||||
ATTRIBUTION,
|
||||
AURORA_API,
|
||||
CONF_THRESHOLD,
|
||||
|
@ -145,12 +137,12 @@ class AuroraEntity(CoordinatorEntity):
|
|||
self._attr_icon = icon
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Define the device based on name."""
|
||||
return {
|
||||
ATTR_IDENTIFIERS: {(DOMAIN, self.unique_id)},
|
||||
ATTR_NAME: self.coordinator.name,
|
||||
ATTR_MANUFACTURER: "NOAA",
|
||||
ATTR_MODEL: "Aurora Visibility Sensor",
|
||||
ATTR_ENTRY_TYPE: "service",
|
||||
}
|
||||
return DeviceInfo(
|
||||
entry_type="service",
|
||||
identifiers={(DOMAIN, str(self.unique_id))},
|
||||
manufacturer="NOAA",
|
||||
model="Aurora Visibility Sensor",
|
||||
name=self.coordinator.name,
|
||||
)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
DOMAIN = "aurora"
|
||||
COORDINATOR = "coordinator"
|
||||
AURORA_API = "aurora_api"
|
||||
ATTR_ENTRY_TYPE = "entry_type"
|
||||
DEFAULT_POLLING_INTERVAL = 5
|
||||
CONF_THRESHOLD = "forecast_threshold"
|
||||
DEFAULT_THRESHOLD = 75
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
"""Base classes for Axis entities."""
|
||||
|
||||
from homeassistant.const import ATTR_IDENTIFIERS
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
|
||||
from .const import DOMAIN as AXIS_DOMAIN
|
||||
|
||||
|
@ -15,7 +14,9 @@ class AxisEntityBase(Entity):
|
|||
"""Initialize the Axis event."""
|
||||
self.device = device
|
||||
|
||||
self._attr_device_info = {ATTR_IDENTIFIERS: {(AXIS_DOMAIN, device.unique_id)}}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(AXIS_DOMAIN, device.unique_id)}
|
||||
)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Subscribe device events."""
|
||||
|
|
|
@ -83,15 +83,9 @@ class AzureDevOpsDeviceEntity(AzureDevOpsEntity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information about this Azure DevOps instance."""
|
||||
return {
|
||||
"identifiers": {
|
||||
( # type: ignore
|
||||
DOMAIN,
|
||||
self.organization,
|
||||
self.project,
|
||||
)
|
||||
},
|
||||
"manufacturer": self.organization,
|
||||
"name": self.project,
|
||||
"entry_type": "service",
|
||||
}
|
||||
return DeviceInfo(
|
||||
entry_type="service",
|
||||
identifiers={(DOMAIN, self.organization, self.project)}, # type: ignore
|
||||
manufacturer=self.organization,
|
||||
name=self.project,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue