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

@ -20,7 +20,7 @@ from homeassistant.const import (
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.dispatcher import dispatcher_send 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 from .const import ATTRIBUTION, DEFAULT_CACHEDB, DOMAIN, LOGGER
@ -322,14 +322,14 @@ class AbodeDevice(AbodeEntity):
} }
@property @property
def device_info(self): def device_info(self) -> DeviceInfo:
"""Return device registry information for this entity.""" """Return device registry information for this entity."""
return { return DeviceInfo(
"identifiers": {(DOMAIN, self._device.device_id)}, identifiers={(DOMAIN, self._device.device_id)},
"manufacturer": "Abode", manufacturer="Abode",
"name": self._device.name, model=self._device.type,
"device_type": self._device.type, name=self._device.name,
} )
def _update_callback(self, device): def _update_callback(self, device):
"""Update the device state.""" """Update the device state."""

View File

@ -7,6 +7,7 @@ from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_NAME, DEVICE_CLASS_TEMPERATURE from homeassistant.const import CONF_NAME, DEVICE_CLASS_TEMPERATURE
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
@ -93,12 +94,12 @@ class AccuWeatherSensor(CoordinatorEntity, SensorEntity):
else: else:
self._unit_system = API_IMPERIAL self._unit_system = API_IMPERIAL
self._attr_native_unit_of_measurement = description.unit_imperial self._attr_native_unit_of_measurement = description.unit_imperial
self._attr_device_info = { self._attr_device_info = DeviceInfo(
"identifiers": {(DOMAIN, coordinator.location_key)}, entry_type="service",
"name": NAME, identifiers={(DOMAIN, coordinator.location_key)},
"manufacturer": MANUFACTURER, manufacturer=MANUFACTURER,
"entry_type": "service", name=NAME,
} )
self.forecast_day = forecast_day self.forecast_day = forecast_day
@property @property

View File

@ -81,7 +81,7 @@ class AcmedaBase(entity.Entity):
"""Return the device info.""" """Return the device info."""
return entity.DeviceInfo( return entity.DeviceInfo(
identifiers={(DOMAIN, self.unique_id)}, identifiers={(DOMAIN, self.unique_id)},
name=self.roller.name,
manufacturer="Rollease Acmeda", manufacturer="Rollease Acmeda",
name=self.roller.name,
via_device=(DOMAIN, self.roller.hub.id), via_device=(DOMAIN, self.roller.hub.id),
) )

View File

@ -196,14 +196,14 @@ class AdGuardHomeDeviceEntity(AdGuardHomeEntity):
@property @property
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return device information about this AdGuard Home instance.""" """Return device information about this AdGuard Home instance."""
return { return DeviceInfo(
"identifiers": { entry_type="service",
identifiers={
(DOMAIN, self.adguard.host, self.adguard.port, self.adguard.base_path) # type: ignore (DOMAIN, self.adguard.host, self.adguard.port, self.adguard.base_path) # type: ignore
}, },
"name": "AdGuard Home", manufacturer="AdGuard Team",
"manufacturer": "AdGuard Team", name="AdGuard Home",
"sw_version": self.hass.data[DOMAIN][self._entry.entry_id].get( sw_version=self.hass.data[DOMAIN][self._entry.entry_id].get(
DATA_ADGUARD_VERSION DATA_ADGUARD_VERSION
), ),
"entry_type": "service", )
}

View File

@ -1,5 +1,6 @@
"""Advantage Air parent entity class.""" """Advantage Air parent entity class."""
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN from .const import DOMAIN
@ -14,13 +15,13 @@ class AdvantageAirEntity(CoordinatorEntity):
self.async_change = instance["async_change"] self.async_change = instance["async_change"]
self.ac_key = ac_key self.ac_key = ac_key
self.zone_key = zone_key self.zone_key = zone_key
self._attr_device_info = { self._attr_device_info = DeviceInfo(
"identifiers": {(DOMAIN, self.coordinator.data["system"]["rid"])}, identifiers={(DOMAIN, self.coordinator.data["system"]["rid"])},
"name": self.coordinator.data["system"]["name"], manufacturer="Advantage Air",
"manufacturer": "Advantage Air", model=self.coordinator.data["system"]["sysType"],
"model": self.coordinator.data["system"]["sysType"], name=self.coordinator.data["system"]["name"],
"sw_version": self.coordinator.data["system"]["myAppRev"], sw_version=self.coordinator.data["system"]["myAppRev"],
} )
@property @property
def _ac(self): def _ac(self):

View File

@ -11,6 +11,7 @@ from homeassistant.const import (
STATE_ALARM_ARMED_NIGHT, STATE_ALARM_ARMED_NIGHT,
STATE_ALARM_DISARMED, STATE_ALARM_DISARMED,
) )
from homeassistant.helpers.entity import DeviceInfo
from .const import CONNECTION, DOMAIN as AGENT_DOMAIN from .const import CONNECTION, DOMAIN as AGENT_DOMAIN
@ -45,12 +46,12 @@ class AgentBaseStation(AlarmControlPanelEntity):
self._client = client self._client = client
self._attr_name = f"{client.name} {CONST_ALARM_CONTROL_PANEL_NAME}" self._attr_name = f"{client.name} {CONST_ALARM_CONTROL_PANEL_NAME}"
self._attr_unique_id = f"{client.unique}_CP" self._attr_unique_id = f"{client.unique}_CP"
self._attr_device_info = { self._attr_device_info = DeviceInfo(
"identifiers": {(AGENT_DOMAIN, client.unique)}, identifiers={(AGENT_DOMAIN, client.unique)},
"manufacturer": "Agent", manufacturer="Agent",
"model": CONST_ALARM_CONTROL_PANEL_NAME, model=CONST_ALARM_CONTROL_PANEL_NAME,
"sw_version": client.version, sw_version=client.version,
} )
async def async_update(self): async def async_update(self):
"""Update the state of the device.""" """Update the state of the device."""

View File

@ -13,6 +13,7 @@ from homeassistant.components.mjpeg.camera import (
) )
from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME
from homeassistant.helpers import entity_platform from homeassistant.helpers import entity_platform
from homeassistant.helpers.entity import DeviceInfo
from .const import ( from .const import (
ATTRIBUTION, ATTRIBUTION,
@ -79,13 +80,13 @@ class AgentCamera(MjpegCamera):
self._attr_name = f"{device.client.name} {device.name}" self._attr_name = f"{device.client.name} {device.name}"
self._attr_unique_id = f"{device._client.unique}_{device.typeID}_{device.id}" self._attr_unique_id = f"{device._client.unique}_{device.typeID}_{device.id}"
super().__init__(device_info) super().__init__(device_info)
self._attr_device_info = { self._attr_device_info = DeviceInfo(
"identifiers": {(AGENT_DOMAIN, self.unique_id)}, identifiers={(AGENT_DOMAIN, self.unique_id)},
"name": self.name, manufacturer="Agent",
"manufacturer": "Agent", model="Camera",
"model": "Camera", name=self.name,
"sw_version": device.client.version, sw_version=device.client.version,
} )
async def async_update(self): async def async_update(self):
"""Update our state from the Agent API.""" """Update our state from the Agent API."""

View File

@ -27,6 +27,7 @@ from homeassistant.const import (
TEMP_CELSIUS, TEMP_CELSIUS,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
@ -151,14 +152,12 @@ class AirlySensor(CoordinatorEntity, SensorEntity):
) -> None: ) -> None:
"""Initialize.""" """Initialize."""
super().__init__(coordinator) super().__init__(coordinator)
self._attr_device_info = { self._attr_device_info = DeviceInfo(
"identifiers": { entry_type="service",
(DOMAIN, f"{coordinator.latitude}-{coordinator.longitude}") identifiers={(DOMAIN, f"{coordinator.latitude}-{coordinator.longitude}")},
}, manufacturer=MANUFACTURER,
"name": DEFAULT_NAME, name=DEFAULT_NAME,
"manufacturer": MANUFACTURER, )
"entry_type": "service",
}
self._attr_name = f"{name} {description.name}" self._attr_name = f"{name} {description.name}"
self._attr_unique_id = ( self._attr_unique_id = (
f"{coordinator.latitude}-{coordinator.longitude}-{description.key}".lower() f"{coordinator.latitude}-{coordinator.longitude}-{description.key}".lower()

View File

@ -21,6 +21,7 @@ from homeassistant.components.climate.const import (
) )
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DOMAIN from .const import DOMAIN
@ -96,14 +97,14 @@ class AirtouchAC(CoordinatorEntity, ClimateEntity):
return super()._handle_coordinator_update() return super()._handle_coordinator_update()
@property @property
def device_info(self): def device_info(self) -> DeviceInfo:
"""Return device info for this device.""" """Return device info for this device."""
return { return DeviceInfo(
"identifiers": {(DOMAIN, self.unique_id)}, identifiers={(DOMAIN, self.unique_id)},
"name": self.name, name=self.name,
"manufacturer": "Airtouch", manufacturer="Airtouch",
"model": "Airtouch 4", model="Airtouch 4",
} )
@property @property
def unique_id(self): def unique_id(self):
@ -211,14 +212,14 @@ class AirtouchGroup(CoordinatorEntity, ClimateEntity):
return super()._handle_coordinator_update() return super()._handle_coordinator_update()
@property @property
def device_info(self): def device_info(self) -> DeviceInfo:
"""Return device info for this device.""" """Return device info for this device."""
return { return DeviceInfo(
"identifiers": {(DOMAIN, self.unique_id)}, identifiers={(DOMAIN, self.unique_id)},
"name": self.name, manufacturer="Airtouch",
"manufacturer": "Airtouch", model="Airtouch 4",
"model": "Airtouch 4", name=self.name,
} )
@property @property
def unique_id(self): def unique_id(self):

View File

@ -319,16 +319,16 @@ class AirVisualNodeProSensor(AirVisualEntity, SensorEntity):
@property @property
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return device registry information for this entity.""" """Return device registry information for this entity."""
return { return DeviceInfo(
"identifiers": {(DOMAIN, self.coordinator.data["serial_number"])}, identifiers={(DOMAIN, self.coordinator.data["serial_number"])},
"name": self.coordinator.data["settings"]["node_name"], manufacturer="AirVisual",
"manufacturer": "AirVisual", model=f'{self.coordinator.data["status"]["model"]}',
"model": f'{self.coordinator.data["status"]["model"]}', name=self.coordinator.data["settings"]["node_name"],
"sw_version": ( sw_version=(
f'Version {self.coordinator.data["status"]["system_version"]}' f'Version {self.coordinator.data["status"]["system_version"]}'
f'{self.coordinator.data["status"]["app_version"]}' f'{self.coordinator.data["status"]["app_version"]}'
), ),
} )
@callback @callback
def update_from_latest_data(self) -> None: def update_from_latest_data(self) -> None:

View File

@ -21,7 +21,6 @@ DOMAIN: Final = "ambee"
LOGGER = logging.getLogger(__package__) LOGGER = logging.getLogger(__package__)
SCAN_INTERVAL = timedelta(hours=1) SCAN_INTERVAL = timedelta(hours=1)
ATTR_ENTRY_TYPE: Final = "entry_type"
ENTRY_TYPE_SERVICE: Final = "service" ENTRY_TYPE_SERVICE: Final = "service"
DEVICE_CLASS_AMBEE_RISK: Final = "ambee__risk" DEVICE_CLASS_AMBEE_RISK: Final = "ambee__risk"

View File

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

View File

@ -21,6 +21,7 @@ from homeassistant.const import (
) )
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.entity import DeviceInfo
from .const import ( from .const import (
ATTR_VALUE, ATTR_VALUE,
@ -149,11 +150,11 @@ class AmbiclimateEntity(ClimateEntity):
self._store = store self._store = store
self._attr_unique_id = heater.device_id self._attr_unique_id = heater.device_id
self._attr_name = heater.name self._attr_name = heater.name
self._attr_device_info = { self._attr_device_info = DeviceInfo(
"identifiers": {(DOMAIN, self.unique_id)}, identifiers={(DOMAIN, self.unique_id)},
"name": self.name, manufacturer="Ambiclimate",
"manufacturer": "Ambiclimate", name=self.name,
} )
async def async_set_temperature(self, **kwargs: Any) -> None: async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperature.""" """Set new target temperature."""

View File

@ -20,7 +20,7 @@ from homeassistant.helpers.dispatcher import (
async_dispatcher_connect, async_dispatcher_connect,
async_dispatcher_send, 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 homeassistant.helpers.event import async_call_later
from .const import ( from .const import (
@ -223,11 +223,11 @@ class AmbientWeatherEntity(Entity):
) -> None: ) -> None:
"""Initialize the entity.""" """Initialize the entity."""
self._ambient = ambient self._ambient = ambient
self._attr_device_info = { self._attr_device_info = DeviceInfo(
"identifiers": {(DOMAIN, mac_address)}, identifiers={(DOMAIN, mac_address)},
"name": station_name, manufacturer="Ambient Weather",
"manufacturer": "Ambient Weather", name=station_name,
} )
self._attr_name = f"{station_name}_{description.name}" self._attr_name = f"{station_name}_{description.name}"
self._attr_unique_id = f"{mac_address}_{description.key}" self._attr_unique_id = f"{mac_address}_{description.key}"
self._mac_address = mac_address self._mac_address = mac_address

View File

@ -22,7 +22,7 @@ from homeassistant.helpers.dispatcher import (
async_dispatcher_connect, async_dispatcher_connect,
async_dispatcher_send, 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 from .const import CONF_CREDENTIALS, CONF_IDENTIFIER, CONF_START_OFF, DOMAIN
@ -91,9 +91,7 @@ class AppleTVEntity(Entity):
self.manager = manager self.manager = manager
self._attr_name = name self._attr_name = name
self._attr_unique_id = identifier self._attr_unique_id = identifier
self._attr_device_info = { self._attr_device_info = DeviceInfo(identifiers={(DOMAIN, identifier)})
"identifiers": {(DOMAIN, identifier)},
}
async def async_added_to_hass(self): async def async_added_to_hass(self):
"""Handle when an entity is about to be added to Home Assistant.""" """Handle when an entity is about to be added to Home Assistant."""

View File

@ -23,6 +23,7 @@ from homeassistant.components.media_player.const import (
from homeassistant.components.media_player.errors import BrowseError from homeassistant.components.media_player.errors import BrowseError
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import DeviceInfo
from .config_flow import get_entry_client from .config_flow import get_entry_client
from .const import ( from .const import (
@ -114,15 +115,15 @@ class ArcamFmj(MediaPlayerEntity):
@property @property
def device_info(self): def device_info(self):
"""Return a device description for device registry.""" """Return a device description for device registry."""
return { return DeviceInfo(
"name": self._device_name, identifiers={
"identifiers": {
(DOMAIN, self._uuid), (DOMAIN, self._uuid),
(DOMAIN, self._state.client.host, self._state.client.port), (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): async def async_added_to_hass(self):
"""Once registered, add listener for events.""" """Once registered, add listener for events."""

View File

@ -81,10 +81,10 @@ class AtagEntity(CoordinatorEntity):
@property @property
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return info for device registry.""" """Return info for device registry."""
return { return DeviceInfo(
"identifiers": {(DOMAIN, self.coordinator.data.id)}, identifiers={(DOMAIN, self.coordinator.data.id)},
"name": "Atag Thermostat", manufacturer="Atag",
"model": "Atag One", model="Atag One",
"sw_version": self.coordinator.data.apiversion, name="Atag Thermostat",
"manufacturer": "Atag", sw_version=self.coordinator.data.apiversion,
} )

View File

@ -1,6 +1,6 @@
"""Base class for August entity.""" """Base class for August entity."""
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import DeviceInfo, Entity
from . import DOMAIN from . import DOMAIN
from .const import MANUFACTURER from .const import MANUFACTURER
@ -18,14 +18,14 @@ class AugustEntityMixin(Entity):
super().__init__() super().__init__()
self._data = data self._data = data
self._device = device self._device = device
self._attr_device_info = { self._attr_device_info = DeviceInfo(
"identifiers": {(DOMAIN, self._device_id)}, identifiers={(DOMAIN, self._device_id)},
"name": device.device_name, manufacturer=MANUFACTURER,
"manufacturer": MANUFACTURER, model=self._detail.model,
"sw_version": self._detail.firmware_version, name=device.device_name,
"model": self._detail.model, sw_version=self._detail.firmware_version,
"suggested_area": _remove_device_types(device.device_name, DEVICE_TYPES), suggested_area=_remove_device_types(device.device_name, DEVICE_TYPES),
} )
@property @property
def _device_id(self): def _device_id(self):

View File

@ -7,17 +7,10 @@ from aiohttp import ClientError
from auroranoaa import AuroraForecast from auroranoaa import AuroraForecast
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME
ATTR_IDENTIFIERS,
ATTR_MANUFACTURER,
ATTR_MODEL,
ATTR_NAME,
CONF_LATITUDE,
CONF_LONGITUDE,
CONF_NAME,
)
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import aiohttp_client from homeassistant.helpers import aiohttp_client
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
DataUpdateCoordinator, DataUpdateCoordinator,
@ -25,7 +18,6 @@ from homeassistant.helpers.update_coordinator import (
) )
from .const import ( from .const import (
ATTR_ENTRY_TYPE,
ATTRIBUTION, ATTRIBUTION,
AURORA_API, AURORA_API,
CONF_THRESHOLD, CONF_THRESHOLD,
@ -145,12 +137,12 @@ class AuroraEntity(CoordinatorEntity):
self._attr_icon = icon self._attr_icon = icon
@property @property
def device_info(self): def device_info(self) -> DeviceInfo:
"""Define the device based on name.""" """Define the device based on name."""
return { return DeviceInfo(
ATTR_IDENTIFIERS: {(DOMAIN, self.unique_id)}, entry_type="service",
ATTR_NAME: self.coordinator.name, identifiers={(DOMAIN, str(self.unique_id))},
ATTR_MANUFACTURER: "NOAA", manufacturer="NOAA",
ATTR_MODEL: "Aurora Visibility Sensor", model="Aurora Visibility Sensor",
ATTR_ENTRY_TYPE: "service", name=self.coordinator.name,
} )

View File

@ -3,7 +3,6 @@
DOMAIN = "aurora" DOMAIN = "aurora"
COORDINATOR = "coordinator" COORDINATOR = "coordinator"
AURORA_API = "aurora_api" AURORA_API = "aurora_api"
ATTR_ENTRY_TYPE = "entry_type"
DEFAULT_POLLING_INTERVAL = 5 DEFAULT_POLLING_INTERVAL = 5
CONF_THRESHOLD = "forecast_threshold" CONF_THRESHOLD = "forecast_threshold"
DEFAULT_THRESHOLD = 75 DEFAULT_THRESHOLD = 75

View File

@ -1,9 +1,8 @@
"""Base classes for Axis entities.""" """Base classes for Axis entities."""
from homeassistant.const import ATTR_IDENTIFIERS
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect 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 from .const import DOMAIN as AXIS_DOMAIN
@ -15,7 +14,9 @@ class AxisEntityBase(Entity):
"""Initialize the Axis event.""" """Initialize the Axis event."""
self.device = device 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): async def async_added_to_hass(self):
"""Subscribe device events.""" """Subscribe device events."""

View File

@ -83,15 +83,9 @@ class AzureDevOpsDeviceEntity(AzureDevOpsEntity):
@property @property
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
"""Return device information about this Azure DevOps instance.""" """Return device information about this Azure DevOps instance."""
return { return DeviceInfo(
"identifiers": { entry_type="service",
( # type: ignore identifiers={(DOMAIN, self.organization, self.project)}, # type: ignore
DOMAIN, manufacturer=self.organization,
self.organization, name=self.project,
self.project, )
)
},
"manufacturer": self.organization,
"name": self.project,
"entry_type": "service",
}