Use DeviceInfo Class N-O (#58314)
parent
0c94fcecf6
commit
2df13d0118
|
@ -84,9 +84,9 @@ class NanoleafLight(LightEntity):
|
|||
self._attr_name = self._nanoleaf.name
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self._nanoleaf.serial_no)},
|
||||
name=self._nanoleaf.name,
|
||||
manufacturer=self._nanoleaf.manufacturer,
|
||||
model=self._nanoleaf.model,
|
||||
name=self._nanoleaf.name,
|
||||
sw_version=self._nanoleaf.firmware_version,
|
||||
)
|
||||
self._attr_min_mireds = math.ceil(
|
||||
|
|
|
@ -132,7 +132,7 @@ class NeatoCleaningMap(Camera):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Device info for neato robot."""
|
||||
return {"identifiers": {(NEATO_DOMAIN, self._robot_serial)}}
|
||||
return DeviceInfo(identifiers={(NEATO_DOMAIN, self._robot_serial)})
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
|
|
|
@ -103,4 +103,4 @@ class NeatoSensor(SensorEntity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Device info for neato robot."""
|
||||
return {"identifiers": {(NEATO_DOMAIN, self._robot_serial)}}
|
||||
return DeviceInfo(identifiers={(NEATO_DOMAIN, self._robot_serial)})
|
||||
|
|
|
@ -109,7 +109,7 @@ class NeatoConnectedSwitch(ToggleEntity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Device info for neato robot."""
|
||||
return {"identifiers": {(NEATO_DOMAIN, self._robot_serial)}}
|
||||
return DeviceInfo(identifiers={(NEATO_DOMAIN, self._robot_serial)})
|
||||
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch on."""
|
||||
|
|
|
@ -338,15 +338,14 @@ class NeatoConnectedVacuum(StateVacuumEntity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Device info for neato robot."""
|
||||
info: DeviceInfo = {
|
||||
"identifiers": {(NEATO_DOMAIN, self._robot_serial)},
|
||||
"name": self._name,
|
||||
}
|
||||
if self._robot_stats:
|
||||
info["manufacturer"] = self._robot_stats["battery"]["vendor"]
|
||||
info["model"] = self._robot_stats["model"]
|
||||
info["sw_version"] = self._robot_stats["firmware"]
|
||||
return info
|
||||
stats = self._robot_stats
|
||||
return DeviceInfo(
|
||||
identifiers={(NEATO_DOMAIN, self._robot_serial)},
|
||||
manufacturer=stats["battery"]["vendor"] if stats else None,
|
||||
model=stats["model"] if stats else None,
|
||||
name=self._name,
|
||||
sw_version=stats["firmware"] if stats else None,
|
||||
)
|
||||
|
||||
def start(self) -> None:
|
||||
"""Start cleaning or resume cleaning."""
|
||||
|
|
|
@ -30,13 +30,11 @@ class NestDeviceInfo:
|
|||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device specific attributes."""
|
||||
return DeviceInfo(
|
||||
{
|
||||
# The API "name" field is a unique device identifier.
|
||||
"identifiers": {(DOMAIN, self._device.name)},
|
||||
"name": self.device_name,
|
||||
"manufacturer": self.device_brand,
|
||||
"model": self.device_model,
|
||||
}
|
||||
identifiers={(DOMAIN, self._device.name)},
|
||||
manufacturer=self.device_brand,
|
||||
model=self.device_model,
|
||||
name=self.device_name,
|
||||
)
|
||||
|
||||
@property
|
||||
|
@ -45,7 +43,7 @@ class NestDeviceInfo:
|
|||
if InfoTrait.NAME in self._device.traits:
|
||||
trait: InfoTrait = self._device.traits[InfoTrait.NAME]
|
||||
if trait.custom_name:
|
||||
return trait.custom_name
|
||||
return str(trait.custom_name)
|
||||
# Build a name from the room/structure. Note: This room/structure name
|
||||
# is not associated with a home assistant Area.
|
||||
if parent_relations := self._device.parent_relations:
|
||||
|
|
|
@ -21,7 +21,7 @@ from homeassistant.const import (
|
|||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
|
||||
from . import local_auth
|
||||
from .const import DATA_NEST, DATA_NEST_CONFIG, DOMAIN, SIGNAL_NEST_UPDATE
|
||||
|
@ -377,7 +377,7 @@ class NestSensorDevice(Entity):
|
|||
return f"{self.device.serial}-{self.variable}"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return information about the device."""
|
||||
if not hasattr(self.device, "name_long"):
|
||||
name = self.structure.name
|
||||
|
@ -393,12 +393,12 @@ class NestSensorDevice(Entity):
|
|||
else:
|
||||
model = None
|
||||
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self.device.serial)},
|
||||
"name": name,
|
||||
"manufacturer": "Nest Labs",
|
||||
"model": model,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.device.serial)},
|
||||
manufacturer="Nest Labs",
|
||||
model=model,
|
||||
name=name,
|
||||
)
|
||||
|
||||
def update(self):
|
||||
"""Do not use NestSensorDevice directly."""
|
||||
|
|
|
@ -7,6 +7,7 @@ import logging
|
|||
import requests
|
||||
|
||||
from homeassistant.components.camera import PLATFORM_SCHEMA, SUPPORT_ON_OFF, Camera
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from .const import DATA_NEST, DOMAIN
|
||||
|
@ -61,14 +62,14 @@ class NestCamera(Camera):
|
|||
return self.device.device_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return information about the device."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self.device.device_id)},
|
||||
"name": self.device.name_long,
|
||||
"manufacturer": "Nest Labs",
|
||||
"model": "Camera",
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.device.device_id)},
|
||||
manufacturer="Nest Labs",
|
||||
model="Camera",
|
||||
name=self.device.name_long,
|
||||
)
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
|
|
|
@ -32,6 +32,7 @@ from homeassistant.const import (
|
|||
TEMP_FAHRENHEIT,
|
||||
)
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from .const import DATA_NEST, DOMAIN, SIGNAL_NEST_UPDATE
|
||||
|
||||
|
@ -166,15 +167,15 @@ class NestThermostat(ClimateEntity):
|
|||
return self.device.serial
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return information about the device."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self.device.device_id)},
|
||||
"name": self.device.name_long,
|
||||
"manufacturer": "Nest Labs",
|
||||
"model": "Thermostat",
|
||||
"sw_version": self.device.software_version,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.device.device_id)},
|
||||
manufacturer="Nest Labs",
|
||||
model="Thermostat",
|
||||
name=self.device.name_long,
|
||||
sw_version=self.device.software_version,
|
||||
)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""The nexia integration base entity."""
|
||||
|
||||
from homeassistant.const import ATTR_ATTRIBUTION
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import (
|
||||
|
@ -11,6 +11,7 @@ from .const import (
|
|||
SIGNAL_THERMOSTAT_UPDATE,
|
||||
SIGNAL_ZONE_UPDATE,
|
||||
)
|
||||
from .coordinator import NexiaDataUpdateCoordinator
|
||||
|
||||
|
||||
class NexiaEntity(CoordinatorEntity):
|
||||
|
@ -49,16 +50,17 @@ class NexiaThermostatEntity(NexiaEntity):
|
|||
self._thermostat = thermostat
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device_info of the device."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._thermostat.thermostat_id)},
|
||||
"name": self._thermostat.get_name(),
|
||||
"model": self._thermostat.get_model(),
|
||||
"sw_version": self._thermostat.get_firmware(),
|
||||
"manufacturer": MANUFACTURER,
|
||||
"configuration_url": self.coordinator.nexia_home.root_url,
|
||||
}
|
||||
assert isinstance(self.coordinator, NexiaDataUpdateCoordinator)
|
||||
return DeviceInfo(
|
||||
configuration_url=self.coordinator.nexia_home.root_url,
|
||||
identifiers={(DOMAIN, self._thermostat.thermostat_id)},
|
||||
manufacturer=MANUFACTURER,
|
||||
model=self._thermostat.get_model(),
|
||||
name=self._thermostat.get_name(),
|
||||
sw_version=self._thermostat.get_firmware(),
|
||||
)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Listen for signals for services."""
|
||||
|
|
|
@ -172,11 +172,11 @@ class NmapTrackerEntity(ScannerEntity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device information."""
|
||||
return {
|
||||
"connections": {(CONNECTION_NETWORK_MAC, self._mac_address)},
|
||||
"default_manufacturer": self._device.manufacturer,
|
||||
"default_name": self.name,
|
||||
}
|
||||
return DeviceInfo(
|
||||
connections={(CONNECTION_NETWORK_MAC, self._mac_address)},
|
||||
default_manufacturer=self._device.manufacturer,
|
||||
default_name=self.name,
|
||||
)
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
|
|
|
@ -5,12 +5,8 @@ import logging
|
|||
|
||||
from homeassistant.components.nut import PyNUTData
|
||||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
||||
from homeassistant.const import (
|
||||
ATTR_IDENTIFIERS,
|
||||
ATTR_NAME,
|
||||
CONF_RESOURCES,
|
||||
STATE_UNKNOWN,
|
||||
)
|
||||
from homeassistant.const import CONF_RESOURCES, STATE_UNKNOWN
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
|
@ -81,10 +77,10 @@ class NUTSensor(CoordinatorEntity, SensorEntity):
|
|||
self._attr_entity_registry_enabled_default = enabled_default
|
||||
self._attr_name = f"{device_name} {sensor_description.name}"
|
||||
self._attr_unique_id = f"{unique_id}_{sensor_description.key}"
|
||||
self._attr_device_info = {
|
||||
ATTR_IDENTIFIERS: {(DOMAIN, unique_id)},
|
||||
ATTR_NAME: device_name,
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, unique_id)},
|
||||
name=device_name,
|
||||
)
|
||||
self._attr_device_info.update(data.device_info)
|
||||
|
||||
@property
|
||||
|
|
|
@ -12,6 +12,7 @@ from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
|
|||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import debounce
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.event import async_track_point_in_utc_time
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
@ -168,11 +169,11 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
return unload_ok
|
||||
|
||||
|
||||
def device_info(latitude, longitude):
|
||||
def device_info(latitude, longitude) -> DeviceInfo:
|
||||
"""Return device registry information."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, base_unique_id(latitude, longitude))},
|
||||
"name": f"NWS: {latitude}, {longitude}",
|
||||
"manufacturer": "National Weather Service",
|
||||
"entry_type": "service",
|
||||
}
|
||||
return DeviceInfo(
|
||||
entry_type="service",
|
||||
identifiers={(DOMAIN, base_unique_id(latitude, longitude))},
|
||||
manufacturer="National Weather Service",
|
||||
name=f"NWS: {latitude}, {longitude}",
|
||||
)
|
||||
|
|
|
@ -6,13 +6,8 @@ import logging
|
|||
from omnilogic import OmniLogic, OmniLogicException
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_IDENTIFIERS,
|
||||
ATTR_MANUFACTURER,
|
||||
ATTR_MODEL,
|
||||
ATTR_NAME,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
|
@ -152,15 +147,14 @@ class OmniLogicEntity(CoordinatorEntity):
|
|||
return self._attrs
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Define the device as back yard/MSP System."""
|
||||
|
||||
return {
|
||||
ATTR_IDENTIFIERS: {(DOMAIN, self._msp_system_id)},
|
||||
ATTR_NAME: self._backyard_name,
|
||||
ATTR_MANUFACTURER: "Hayward",
|
||||
ATTR_MODEL: "OmniLogic",
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._msp_system_id)},
|
||||
manufacturer="Hayward",
|
||||
model="OmniLogic",
|
||||
name=self._backyard_name,
|
||||
)
|
||||
|
||||
|
||||
def check_guard(state_key, item, entity_setting):
|
||||
|
|
|
@ -16,6 +16,7 @@ from homeassistant.const import (
|
|||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
)
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
|
@ -169,13 +170,13 @@ class OndiloICO(CoordinatorEntity, SensorEntity):
|
|||
return self._devdata()["value"]
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info for the sensor."""
|
||||
pooldata = self._pooldata()
|
||||
return {
|
||||
"identifiers": {(DOMAIN, pooldata["ICO"]["serial_number"])},
|
||||
"name": self._device_name,
|
||||
"manufacturer": "Ondilo",
|
||||
"model": "ICO",
|
||||
"sw_version": pooldata["ICO"]["sw_version"],
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, pooldata["ICO"]["serial_number"])},
|
||||
manufacturer="Ondilo",
|
||||
model="ICO",
|
||||
name=self._device_name,
|
||||
sw_version=pooldata["ICO"]["sw_version"],
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Base classes for ONVIF entities."""
|
||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
|
||||
from .const import DOMAIN
|
||||
from .device import ONVIFDevice
|
||||
|
@ -21,14 +21,14 @@ class ONVIFBaseEntity(Entity):
|
|||
return self.device.available
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return a device description for device registry."""
|
||||
device_info = {
|
||||
"manufacturer": self.device.info.manufacturer,
|
||||
"model": self.device.info.model,
|
||||
"name": self.device.name,
|
||||
"sw_version": self.device.info.fw_version,
|
||||
"identifiers": {
|
||||
connections = None
|
||||
if self.device.info.mac:
|
||||
connections = {(CONNECTION_NETWORK_MAC, self.device.info.mac)}
|
||||
return DeviceInfo(
|
||||
connections=connections,
|
||||
identifiers={
|
||||
# MAC address is not always available, and given the number
|
||||
# of non-conformant ONVIF devices we have historically supported,
|
||||
# we can not guarantee serial number either. Due to this, we have
|
||||
|
@ -37,11 +37,8 @@ class ONVIFBaseEntity(Entity):
|
|||
# See: https://github.com/home-assistant/core/issues/35883
|
||||
(DOMAIN, self.device.info.mac or self.device.info.serial_number)
|
||||
},
|
||||
}
|
||||
|
||||
if self.device.info.mac:
|
||||
device_info["connections"] = {
|
||||
(CONNECTION_NETWORK_MAC, self.device.info.mac)
|
||||
}
|
||||
|
||||
return device_info
|
||||
manufacturer=self.device.info.manufacturer,
|
||||
model=self.device.info.model,
|
||||
name=self.device.name,
|
||||
sw_version=self.device.info.fw_version,
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ from homeassistant.components.binary_sensor import ENTITY_ID_FORMAT, BinarySenso
|
|||
from homeassistant.const import CONF_ID
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import async_generate_entity_id
|
||||
from homeassistant.helpers.entity import DeviceInfo, async_generate_entity_id
|
||||
from homeassistant.helpers.entity_registry import async_get_registry
|
||||
|
||||
from . import DOMAIN
|
||||
|
@ -131,15 +131,15 @@ class OpenThermBinarySensor(BinarySensorEntity):
|
|||
return self._friendly_name
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._gateway.gw_id)},
|
||||
"name": self._gateway.name,
|
||||
"manufacturer": "Schelte Bron",
|
||||
"model": "OpenTherm Gateway",
|
||||
"sw_version": self._gateway.gw_version,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._gateway.gw_id)},
|
||||
manufacturer="Schelte Bron",
|
||||
model="OpenTherm Gateway",
|
||||
name=self._gateway.name,
|
||||
sw_version=self._gateway.gw_version,
|
||||
)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
|
|
@ -25,7 +25,7 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import async_generate_entity_id
|
||||
from homeassistant.helpers.entity import DeviceInfo, async_generate_entity_id
|
||||
|
||||
from . import DOMAIN
|
||||
from .const import (
|
||||
|
@ -171,15 +171,15 @@ class OpenThermClimate(ClimateEntity):
|
|||
return self.friendly_name
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._gateway.gw_id)},
|
||||
"name": self._gateway.name,
|
||||
"manufacturer": "Schelte Bron",
|
||||
"model": "OpenTherm Gateway",
|
||||
"sw_version": self._gateway.gw_version,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._gateway.gw_id)},
|
||||
manufacturer="Schelte Bron",
|
||||
model="OpenTherm Gateway",
|
||||
name=self._gateway.name,
|
||||
sw_version=self._gateway.gw_version,
|
||||
)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
|
|
@ -6,7 +6,7 @@ from homeassistant.components.sensor import ENTITY_ID_FORMAT, SensorEntity
|
|||
from homeassistant.const import CONF_ID
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import async_generate_entity_id
|
||||
from homeassistant.helpers.entity import DeviceInfo, async_generate_entity_id
|
||||
from homeassistant.helpers.entity_registry import async_get_registry
|
||||
|
||||
from . import DOMAIN
|
||||
|
@ -135,15 +135,15 @@ class OpenThermSensor(SensorEntity):
|
|||
return self._friendly_name
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._gateway.gw_id)},
|
||||
"name": self._gateway.name,
|
||||
"manufacturer": "Schelte Bron",
|
||||
"model": "OpenTherm Gateway",
|
||||
"sw_version": self._gateway.gw_version,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._gateway.gw_id)},
|
||||
manufacturer="Schelte Bron",
|
||||
model="OpenTherm Gateway",
|
||||
name=self._gateway.name,
|
||||
sw_version=self._gateway.gw_version,
|
||||
)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
||||
from homeassistant.const import ATTR_ATTRIBUTION
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
from .const import (
|
||||
|
@ -70,12 +71,12 @@ class AbstractOpenWeatherMapSensor(SensorEntity):
|
|||
self._attr_name = f"{name} {description.name}"
|
||||
self._attr_unique_id = unique_id
|
||||
split_unique_id = unique_id.split("-")
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(DOMAIN, f"{split_unique_id[0]}-{split_unique_id[1]}")},
|
||||
"name": DEFAULT_NAME,
|
||||
"manufacturer": MANUFACTURER,
|
||||
"entry_type": "service",
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
entry_type="service",
|
||||
identifiers={(DOMAIN, f"{split_unique_id[0]}-{split_unique_id[1]}")},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=DEFAULT_NAME,
|
||||
)
|
||||
|
||||
@property
|
||||
def attribution(self):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Support for the OpenWeatherMap (OWM) service."""
|
||||
from homeassistant.components.weather import WeatherEntity
|
||||
from homeassistant.const import PRESSURE_HPA, PRESSURE_INHG, TEMP_CELSIUS
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.util.pressure import convert as pressure_convert
|
||||
|
||||
from .const import (
|
||||
|
@ -58,14 +59,14 @@ class OpenWeatherMapWeather(WeatherEntity):
|
|||
return self._unique_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._unique_id)},
|
||||
"name": DEFAULT_NAME,
|
||||
"manufacturer": MANUFACTURER,
|
||||
"entry_type": "service",
|
||||
}
|
||||
return DeviceInfo(
|
||||
entry_type="service",
|
||||
identifiers={(DOMAIN, self._unique_id)},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=DEFAULT_NAME,
|
||||
)
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
|
|
|
@ -111,9 +111,9 @@ class OVOEnergyDeviceEntity(OVOEnergyEntity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information about this OVO Energy instance."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._client.account_id)},
|
||||
"manufacturer": "OVO Energy",
|
||||
"name": self._client.username,
|
||||
"entry_type": "service",
|
||||
}
|
||||
return DeviceInfo(
|
||||
entry_type="service",
|
||||
identifiers={(DOMAIN, self._client.account_id)},
|
||||
manufacturer="OVO Energy",
|
||||
name=self._client.username,
|
||||
)
|
||||
|
|
|
@ -13,6 +13,7 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import device_registry
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
from . import DOMAIN as OT_DOMAIN
|
||||
|
@ -117,9 +118,9 @@ class OwnTracksEntity(TrackerEntity, RestoreEntity):
|
|||
return self._data.get("source_type", SOURCE_TYPE_GPS)
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
return {"name": self.name, "identifiers": {(OT_DOMAIN, self._dev_id)}}
|
||||
return DeviceInfo(identifiers={(OT_DOMAIN, self._dev_id)}, name=self.name)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Call when entity about to be added to Home Assistant."""
|
||||
|
|
Loading…
Reference in New Issue