Use DeviceInfo Class F-G (#58255)
This commit is contained in:
parent
12c067970a
commit
63646a19cc
31 changed files with 207 additions and 214 deletions
|
@ -19,13 +19,13 @@ class FirmataEntity:
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info."""
|
||||
return {
|
||||
"connections": {},
|
||||
"identifiers": {(DOMAIN, self._api.board.name)},
|
||||
"manufacturer": FIRMATA_MANUFACTURER,
|
||||
"name": self._api.board.name,
|
||||
"sw_version": self._api.board.firmware_version,
|
||||
}
|
||||
return DeviceInfo(
|
||||
connections={},
|
||||
identifiers={(DOMAIN, self._api.board.name)},
|
||||
manufacturer=FIRMATA_MANUFACTURER,
|
||||
name=self._api.board.name,
|
||||
sw_version=self._api.board.firmware_version,
|
||||
)
|
||||
|
||||
|
||||
class FirmataPinEntity(FirmataEntity):
|
||||
|
|
|
@ -89,11 +89,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
)
|
||||
coordinator.async_set_updated_data(device.state)
|
||||
|
||||
device_info: DeviceInfo = {
|
||||
"identifiers": {(DOMAIN, ble_device.address)},
|
||||
"manufacturer": "Fjäråskupan",
|
||||
"name": "Fjäråskupan",
|
||||
}
|
||||
device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, ble_device.address)},
|
||||
manufacturer="Fjäråskupan",
|
||||
name="Fjäråskupan",
|
||||
)
|
||||
device_state = DeviceState(device, coordinator, device_info)
|
||||
state.devices[ble_device.address] = device_state
|
||||
async_dispatcher_send(
|
||||
|
|
|
@ -7,7 +7,7 @@ from flipr_api import FliprAPIRestClient
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_ATTRIBUTION, CONF_EMAIL, CONF_PASSWORD
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
from homeassistant.helpers.entity import DeviceInfo, EntityDescription
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
|
@ -88,10 +88,10 @@ class FliprEntity(CoordinatorEntity):
|
|||
flipr_id = coordinator.config_entry.data[CONF_FLIPR_ID]
|
||||
self._attr_unique_id = f"{flipr_id}-{description.key}"
|
||||
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(DOMAIN, flipr_id)},
|
||||
"name": NAME,
|
||||
"manufacturer": MANUFACTURER,
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, flipr_id)},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=NAME,
|
||||
)
|
||||
|
||||
self._attr_name = f"Flipr {flipr_id} {description.name}"
|
||||
|
|
|
@ -33,14 +33,14 @@ class FloEntity(Entity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return a device description for device registry."""
|
||||
return {
|
||||
"identifiers": {(FLO_DOMAIN, self._device.id)},
|
||||
"connections": {(CONNECTION_NETWORK_MAC, self._device.mac_address)},
|
||||
"manufacturer": self._device.manufacturer,
|
||||
"model": self._device.model,
|
||||
"name": self._device.device_name,
|
||||
"sw_version": self._device.firmware_version,
|
||||
}
|
||||
return DeviceInfo(
|
||||
connections={(CONNECTION_NETWORK_MAC, self._device.mac_address)},
|
||||
identifiers={(FLO_DOMAIN, self._device.id)},
|
||||
manufacturer=self._device.manufacturer,
|
||||
model=self._device.model,
|
||||
name=self._device.device_name,
|
||||
sw_version=self._device.firmware_version,
|
||||
)
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
|
|
|
@ -20,6 +20,7 @@ from homeassistant.const import (
|
|||
CONF_USERNAME,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
|
@ -132,12 +133,12 @@ class FlumeSensor(CoordinatorEntity, SensorEntity):
|
|||
|
||||
self._attr_name = f"{name} {description.name}"
|
||||
self._attr_unique_id = f"{description.key}_{device_id}"
|
||||
self._attr_device_info = {
|
||||
"name": self.name,
|
||||
"identifiers": {(DOMAIN, device_id)},
|
||||
"manufacturer": "Flume, Inc.",
|
||||
"model": "Flume Smart Water Monitor",
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, device_id)},
|
||||
manufacturer="Flume, Inc.",
|
||||
model="Flume Smart Water Monitor",
|
||||
name=self.name,
|
||||
)
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
|
|
|
@ -6,15 +6,10 @@ from typing import Any, cast
|
|||
|
||||
from flux_led.aiodevice import AIOWifiLedBulb
|
||||
|
||||
from homeassistant.const import (
|
||||
ATTR_MANUFACTURER,
|
||||
ATTR_MODEL,
|
||||
ATTR_NAME,
|
||||
ATTR_SW_VERSION,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from . import FluxLedUpdateCoordinator
|
||||
|
@ -39,13 +34,13 @@ class FluxEntity(CoordinatorEntity):
|
|||
self._attr_name = name
|
||||
self._attr_unique_id = unique_id
|
||||
if self.unique_id:
|
||||
self._attr_device_info = {
|
||||
"connections": {(dr.CONNECTION_NETWORK_MAC, self.unique_id)},
|
||||
ATTR_MODEL: self._device.model,
|
||||
ATTR_NAME: self.name,
|
||||
ATTR_SW_VERSION: str(self._device.version_num),
|
||||
ATTR_MANUFACTURER: "FluxLED/Magic Home",
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
connections={(dr.CONNECTION_NETWORK_MAC, self.unique_id)},
|
||||
manufacturer="FluxLED/Magic Home",
|
||||
model=self._device.model,
|
||||
name=self.name,
|
||||
sw_version=str(self._device.version_num),
|
||||
)
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
|
|
|
@ -5,13 +5,8 @@ from datetime import datetime
|
|||
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN, SensorEntity
|
||||
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.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
|
@ -19,7 +14,7 @@ from homeassistant.helpers.update_coordinator import (
|
|||
DataUpdateCoordinator,
|
||||
)
|
||||
|
||||
from .const import ATTR_ENTRY_TYPE, DOMAIN, ENTRY_TYPE_SERVICE, SENSORS
|
||||
from .const import DOMAIN, ENTRY_TYPE_SERVICE, SENSORS
|
||||
from .models import ForecastSolarSensorEntityDescription
|
||||
|
||||
|
||||
|
@ -57,13 +52,13 @@ class ForecastSolarSensorEntity(CoordinatorEntity, SensorEntity):
|
|||
self.entity_id = f"{SENSOR_DOMAIN}.{entity_description.key}"
|
||||
self._attr_unique_id = f"{entry_id}_{entity_description.key}"
|
||||
|
||||
self._attr_device_info = {
|
||||
ATTR_IDENTIFIERS: {(DOMAIN, entry_id)},
|
||||
ATTR_NAME: "Solar Production Forecast",
|
||||
ATTR_MANUFACTURER: "Forecast.Solar",
|
||||
ATTR_MODEL: coordinator.data.account_type.value,
|
||||
ATTR_ENTRY_TYPE: ENTRY_TYPE_SERVICE,
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
entry_type=ENTRY_TYPE_SERVICE,
|
||||
identifiers={(DOMAIN, entry_id)},
|
||||
manufacturer="Forecast.Solar",
|
||||
model=coordinator.data.account_type.value,
|
||||
name="Solar Production Forecast",
|
||||
)
|
||||
|
||||
@property
|
||||
def native_value(self) -> StateType:
|
||||
|
|
|
@ -114,12 +114,12 @@ class FreeboxDevice(ScannerEntity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device information."""
|
||||
return {
|
||||
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
|
||||
"identifiers": {(DOMAIN, self.unique_id)},
|
||||
"name": self.name,
|
||||
"manufacturer": self._manufacturer,
|
||||
}
|
||||
return DeviceInfo(
|
||||
connections={(CONNECTION_NETWORK_MAC, self._mac)},
|
||||
identifiers={(DOMAIN, self.unique_id)},
|
||||
manufacturer=self._manufacturer,
|
||||
name=self.name,
|
||||
)
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
|
|
|
@ -183,13 +183,13 @@ class FreeboxRouter:
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device information."""
|
||||
return {
|
||||
"connections": {(CONNECTION_NETWORK_MAC, self.mac)},
|
||||
"identifiers": {(DOMAIN, self.mac)},
|
||||
"name": self.name,
|
||||
"manufacturer": "Freebox SAS",
|
||||
"sw_version": self._sw_v,
|
||||
}
|
||||
return DeviceInfo(
|
||||
connections={(CONNECTION_NETWORK_MAC, self.mac)},
|
||||
identifiers={(DOMAIN, self.mac)},
|
||||
manufacturer="Freebox SAS",
|
||||
name=self.name,
|
||||
sw_version=self._sw_v,
|
||||
)
|
||||
|
||||
@property
|
||||
def signal_device_new(self) -> str:
|
||||
|
|
|
@ -165,8 +165,8 @@ class FreeboxDiskSensor(FreeboxSensor):
|
|||
"""Return the device information."""
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._disk["id"])},
|
||||
name=f"Disk {self._disk['id']}",
|
||||
model=self._disk["model"],
|
||||
name=f"Disk {self._disk['id']}",
|
||||
sw_version=self._disk["firmware"],
|
||||
via_device=(
|
||||
DOMAIN,
|
||||
|
|
|
@ -7,6 +7,7 @@ from homeassistant.components.binary_sensor import (
|
|||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -47,14 +48,14 @@ class Device(CoordinatorEntity, BinarySensorEntity):
|
|||
self._attr_name = device["name"]
|
||||
self._attr_unique_id = device["uid"]
|
||||
self._type = device["type"]
|
||||
self._attr_device_info = {
|
||||
"name": self.name,
|
||||
"identifiers": {
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, self.unique_id),
|
||||
},
|
||||
"model": device["type"],
|
||||
"manufacturer": "Freedompro",
|
||||
}
|
||||
manufacturer="Freedompro",
|
||||
model=device["type"],
|
||||
name=self.name,
|
||||
)
|
||||
self._attr_device_class = DEVICE_CLASS_MAP[device["type"]]
|
||||
|
||||
@callback
|
||||
|
|
|
@ -15,6 +15,7 @@ from homeassistant.components.climate.const import (
|
|||
from homeassistant.const import ATTR_TEMPERATURE, CONF_API_KEY, TEMP_CELSIUS
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -59,14 +60,14 @@ class Device(CoordinatorEntity, ClimateEntity):
|
|||
self._attr_name = device["name"]
|
||||
self._attr_unique_id = device["uid"]
|
||||
self._characteristics = device["characteristics"]
|
||||
self._attr_device_info = {
|
||||
"name": self.name,
|
||||
"identifiers": {
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, self.unique_id),
|
||||
},
|
||||
"model": device["type"],
|
||||
"manufacturer": "Freedompro",
|
||||
}
|
||||
manufacturer="Freedompro",
|
||||
model=device["type"],
|
||||
name=self.name,
|
||||
)
|
||||
self._attr_supported_features = SUPPORT_TARGET_TEMPERATURE
|
||||
self._attr_current_temperature = 0
|
||||
self._attr_target_temperature = 0
|
||||
|
|
|
@ -18,6 +18,7 @@ from homeassistant.components.cover import (
|
|||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -54,14 +55,14 @@ class Device(CoordinatorEntity, CoverEntity):
|
|||
self._api_key = api_key
|
||||
self._attr_name = device["name"]
|
||||
self._attr_unique_id = device["uid"]
|
||||
self._attr_device_info = {
|
||||
"name": self.name,
|
||||
"identifiers": {
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, self.unique_id),
|
||||
},
|
||||
"model": device["type"],
|
||||
"manufacturer": "Freedompro",
|
||||
}
|
||||
manufacturer="Freedompro",
|
||||
model=device["type"],
|
||||
name=self.name,
|
||||
)
|
||||
self._attr_current_cover_position = 0
|
||||
self._attr_is_closed = True
|
||||
self._attr_supported_features = (
|
||||
|
|
|
@ -7,6 +7,7 @@ from homeassistant.components.fan import SUPPORT_SET_SPEED, FanEntity
|
|||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -34,14 +35,14 @@ class FreedomproFan(CoordinatorEntity, FanEntity):
|
|||
self._attr_name = device["name"]
|
||||
self._attr_unique_id = device["uid"]
|
||||
self._characteristics = device["characteristics"]
|
||||
self._attr_device_info = {
|
||||
"name": self.name,
|
||||
"identifiers": {
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, self.unique_id),
|
||||
},
|
||||
"model": device["type"],
|
||||
"manufacturer": "Freedompro",
|
||||
}
|
||||
manufacturer="Freedompro",
|
||||
model=device["type"],
|
||||
name=self.name,
|
||||
)
|
||||
self._attr_is_on = False
|
||||
self._attr_percentage = 0
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ from homeassistant.components.light import (
|
|||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -40,14 +41,14 @@ class Device(CoordinatorEntity, LightEntity):
|
|||
self._api_key = api_key
|
||||
self._attr_name = device["name"]
|
||||
self._attr_unique_id = device["uid"]
|
||||
self._attr_device_info = {
|
||||
"name": self.name,
|
||||
"identifiers": {
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, self.unique_id),
|
||||
},
|
||||
"model": device["type"],
|
||||
"manufacturer": "Freedompro",
|
||||
}
|
||||
manufacturer="Freedompro",
|
||||
model=device["type"],
|
||||
name=self.name,
|
||||
)
|
||||
self._attr_is_on = False
|
||||
self._attr_brightness = 0
|
||||
color_mode = COLOR_MODE_ONOFF
|
||||
|
|
|
@ -7,6 +7,7 @@ from homeassistant.components.lock import LockEntity
|
|||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -36,14 +37,14 @@ class Device(CoordinatorEntity, LockEntity):
|
|||
self._attr_unique_id = device["uid"]
|
||||
self._type = device["type"]
|
||||
self._characteristics = device["characteristics"]
|
||||
self._attr_device_info = {
|
||||
"name": self.name,
|
||||
"identifiers": {
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, self.unique_id),
|
||||
},
|
||||
"model": self._type,
|
||||
"manufacturer": "Freedompro",
|
||||
}
|
||||
manufacturer="Freedompro",
|
||||
model=self._type,
|
||||
name=self.name,
|
||||
)
|
||||
|
||||
@callback
|
||||
def _handle_coordinator_update(self) -> None:
|
||||
|
|
|
@ -8,6 +8,7 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.const import LIGHT_LUX, PERCENTAGE, TEMP_CELSIUS
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -54,14 +55,14 @@ class Device(CoordinatorEntity, SensorEntity):
|
|||
self._attr_name = device["name"]
|
||||
self._attr_unique_id = device["uid"]
|
||||
self._type = device["type"]
|
||||
self._attr_device_info = {
|
||||
"name": self.name,
|
||||
"identifiers": {
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, self.unique_id),
|
||||
},
|
||||
"model": device["type"],
|
||||
"manufacturer": "Freedompro",
|
||||
}
|
||||
manufacturer="Freedompro",
|
||||
model=device["type"],
|
||||
name=self.name,
|
||||
)
|
||||
self._attr_device_class = DEVICE_CLASS_MAP[device["type"]]
|
||||
self._attr_state_class = STATE_CLASS_MAP[device["type"]]
|
||||
self._attr_native_unit_of_measurement = UNIT_MAP[device["type"]]
|
||||
|
|
|
@ -7,6 +7,7 @@ from homeassistant.components.switch import SwitchEntity
|
|||
from homeassistant.const import CONF_API_KEY
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
|
@ -33,14 +34,14 @@ class Device(CoordinatorEntity, SwitchEntity):
|
|||
self._api_key = api_key
|
||||
self._attr_name = device["name"]
|
||||
self._attr_unique_id = device["uid"]
|
||||
self._attr_device_info = {
|
||||
"name": self.name,
|
||||
"identifiers": {
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, self.unique_id),
|
||||
},
|
||||
"model": device["type"],
|
||||
"manufacturer": "Freedompro",
|
||||
}
|
||||
manufacturer="Freedompro",
|
||||
model=device["type"],
|
||||
name=self.name,
|
||||
)
|
||||
self._attr_is_on = False
|
||||
|
||||
@callback
|
||||
|
|
|
@ -353,10 +353,10 @@ class FritzDeviceBase(Entity):
|
|||
"""Return the device information."""
|
||||
return DeviceInfo(
|
||||
connections={(CONNECTION_NETWORK_MAC, self._mac)},
|
||||
identifiers={(DOMAIN, self._mac)},
|
||||
default_name=self.name,
|
||||
default_manufacturer="AVM",
|
||||
default_model="FRITZ!Box Tracked device",
|
||||
default_name=self.name,
|
||||
identifiers={(DOMAIN, self._mac)},
|
||||
via_device=(
|
||||
DOMAIN,
|
||||
self._router.unique_id,
|
||||
|
@ -479,13 +479,12 @@ class FritzBoxBaseEntity:
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device information."""
|
||||
|
||||
return DeviceInfo(
|
||||
configuration_url=f"http://{self._fritzbox_tools.host}",
|
||||
connections={(CONNECTION_NETWORK_MAC, self.mac_address)},
|
||||
identifiers={(DOMAIN, self._fritzbox_tools.unique_id)},
|
||||
name=self._device_name,
|
||||
manufacturer="AVM",
|
||||
model=self._fritzbox_tools.model,
|
||||
name=self._device_name,
|
||||
sw_version=self._fritzbox_tools.current_firmware,
|
||||
configuration_url=f"http://{self._fritzbox_tools.host}",
|
||||
)
|
||||
|
|
|
@ -173,13 +173,13 @@ class FritzBoxEntity(CoordinatorEntity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device specific attributes."""
|
||||
return {
|
||||
"name": self.device.name,
|
||||
"identifiers": {(DOMAIN, self.ain)},
|
||||
"manufacturer": self.device.manufacturer,
|
||||
"model": self.device.productname,
|
||||
"sw_version": self.device.fw_version,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.ain)},
|
||||
manufacturer=self.device.manufacturer,
|
||||
model=self.device.productname,
|
||||
name=self.device.name,
|
||||
sw_version=self.device.fw_version,
|
||||
)
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> FritzExtraAttributes:
|
||||
|
|
|
@ -19,6 +19,7 @@ from homeassistant.const import (
|
|||
EVENT_HOMEASSISTANT_STOP,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from .const import (
|
||||
ATTR_PREFIXES,
|
||||
|
@ -175,15 +176,15 @@ class FritzBoxCallSensor(SensorEntity):
|
|||
return self._attributes
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device specific attributes."""
|
||||
return {
|
||||
"name": self._fritzbox_phonebook.fph.modelname,
|
||||
"identifiers": {(DOMAIN, self._unique_id)},
|
||||
"manufacturer": MANUFACTURER,
|
||||
"model": self._fritzbox_phonebook.fph.modelname,
|
||||
"sw_version": self._fritzbox_phonebook.fph.fc.system_version,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._unique_id)},
|
||||
manufacturer=MANUFACTURER,
|
||||
model=self._fritzbox_phonebook.fph.modelname,
|
||||
name=self._fritzbox_phonebook.fph.modelname,
|
||||
sw_version=self._fritzbox_phonebook.fph.fc.system_version,
|
||||
)
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
|
|
@ -5,6 +5,7 @@ from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE
|
|||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import device_registry
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
from . import DOMAIN as GF_DOMAIN, TRACKER_UPDATE
|
||||
|
@ -86,9 +87,9 @@ class GeofencyEntity(TrackerEntity, RestoreEntity):
|
|||
return self._unique_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
return {"name": self._name, "identifiers": {(GF_DOMAIN, self._unique_id)}}
|
||||
return DeviceInfo(identifiers={(GF_DOMAIN, self._unique_id)}, name=self._name)
|
||||
|
||||
@property
|
||||
def source_type(self):
|
||||
|
|
|
@ -8,6 +8,7 @@ from homeassistant.components.sensor import DOMAIN as PLATFORM, SensorEntity
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_ATTRIBUTION, ATTR_NAME, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.entity_registry import async_get_registry
|
||||
from homeassistant.helpers.typing import StateType
|
||||
|
@ -80,12 +81,12 @@ class GiosSensor(CoordinatorEntity, SensorEntity):
|
|||
) -> None:
|
||||
"""Initialize."""
|
||||
super().__init__(coordinator)
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(DOMAIN, str(coordinator.gios.station_id))},
|
||||
"name": DEFAULT_NAME,
|
||||
"manufacturer": MANUFACTURER,
|
||||
"entry_type": "service",
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
entry_type="service",
|
||||
identifiers={(DOMAIN, str(coordinator.gios.station_id))},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=DEFAULT_NAME,
|
||||
)
|
||||
self._attr_name = f"{name} {description.name}"
|
||||
self._attr_unique_id = f"{coordinator.gios.station_id}-{description.key}"
|
||||
self._attrs: dict[str, Any] = {
|
||||
|
|
|
@ -9,16 +9,7 @@ from homeassistant.components.binary_sensor import DOMAIN as DOMAIN_BINARY_SENSO
|
|||
from homeassistant.components.sensor import DOMAIN as DOMAIN_SENSOR
|
||||
from homeassistant.components.switch import DOMAIN as DOMAIN_SWITCH
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
ATTR_IDENTIFIERS,
|
||||
ATTR_MANUFACTURER,
|
||||
ATTR_MODEL,
|
||||
ATTR_NAME,
|
||||
ATTR_SW_VERSION,
|
||||
CONF_HOST,
|
||||
CONF_NAME,
|
||||
)
|
||||
from homeassistant.const import ATTR_ATTRIBUTION, ATTR_MODEL, CONF_HOST, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
@ -109,10 +100,10 @@ class YetiEntity(CoordinatorEntity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device information of the entity."""
|
||||
return {
|
||||
ATTR_IDENTIFIERS: {(DOMAIN, self._server_unique_id)},
|
||||
ATTR_MANUFACTURER: "Goal Zero",
|
||||
ATTR_NAME: self._name,
|
||||
ATTR_MODEL: self.api.sysdata[ATTR_MODEL],
|
||||
ATTR_SW_VERSION: self.api.data["firmwareVersion"],
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._server_unique_id)},
|
||||
manufacturer="Goal Zero",
|
||||
model=self.api.sysdata[ATTR_MODEL],
|
||||
name=self._name,
|
||||
sw_version=self.api.data["firmwareVersion"],
|
||||
)
|
||||
|
|
|
@ -93,21 +93,20 @@ class GoGoGate2Entity(CoordinatorEntity):
|
|||
return self._door
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Device info for the controller."""
|
||||
data = self.coordinator.data
|
||||
info: DeviceInfo = {
|
||||
"identifiers": {(DOMAIN, self._config_entry.unique_id)},
|
||||
"name": self._config_entry.title,
|
||||
"manufacturer": MANUFACTURER,
|
||||
"model": data.model,
|
||||
"sw_version": data.firmwareversion,
|
||||
}
|
||||
url = None
|
||||
if data.model.startswith("ismartgate"):
|
||||
info[
|
||||
"configuration_url"
|
||||
] = f"https://{self._config_entry.unique_id}.isgaccess.com"
|
||||
return info
|
||||
url = f"https://{self._config_entry.unique_id}.isgaccess.com"
|
||||
return DeviceInfo(
|
||||
configuration_url=url,
|
||||
identifiers={(DOMAIN, str(self._config_entry.unique_id))},
|
||||
name=self._config_entry.title,
|
||||
manufacturer=MANUFACTURER,
|
||||
model=data.model,
|
||||
sw_version=data.firmwareversion,
|
||||
)
|
||||
|
||||
|
||||
def get_data_update_coordinator(
|
||||
|
|
|
@ -22,6 +22,7 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import CoreState, HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
|
@ -209,13 +210,13 @@ class GoogleTravelTimeSensor(SensorEntity):
|
|||
return None
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device specific attributes."""
|
||||
return {
|
||||
"name": DOMAIN,
|
||||
"identifiers": {(DOMAIN, self._api_key)},
|
||||
"entry_type": "service",
|
||||
}
|
||||
return DeviceInfo(
|
||||
entry_type="service",
|
||||
identifiers={(DOMAIN, self._api_key)},
|
||||
name=DOMAIN,
|
||||
)
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
|
|
|
@ -11,6 +11,7 @@ from homeassistant.const import (
|
|||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import device_registry
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
from . import DOMAIN as GPL_DOMAIN, TRACKER_UPDATE
|
||||
|
@ -111,9 +112,9 @@ class GPSLoggerEntity(TrackerEntity, RestoreEntity):
|
|||
return self._unique_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
return {"name": self._name, "identifiers": {(GPL_DOMAIN, self._unique_id)}}
|
||||
return DeviceInfo(identifiers={(GPL_DOMAIN, self._unique_id)}, name=self._name)
|
||||
|
||||
@property
|
||||
def source_type(self):
|
||||
|
|
|
@ -50,6 +50,7 @@ from homeassistant.const import (
|
|||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import (
|
||||
|
@ -137,14 +138,14 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity):
|
|||
return self._mac
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device specific attributes."""
|
||||
return {
|
||||
"name": self._name,
|
||||
"identifiers": {(DOMAIN, self._mac)},
|
||||
"manufacturer": "Gree",
|
||||
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
|
||||
}
|
||||
return DeviceInfo(
|
||||
connections={(CONNECTION_NETWORK_MAC, self._mac)},
|
||||
identifiers={(DOMAIN, self._mac)},
|
||||
manufacturer="Gree",
|
||||
name=self._name,
|
||||
)
|
||||
|
||||
@property
|
||||
def temperature_unit(self) -> str:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""Entity object for shared properties of Gree entities."""
|
||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .bridge import DeviceDataUpdateCoordinator
|
||||
|
@ -27,11 +28,11 @@ class GreeEntity(CoordinatorEntity):
|
|||
return f"{self._mac}_{self._desc}"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return info about the device."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._mac)},
|
||||
"name": self._name,
|
||||
"manufacturer": "Gree",
|
||||
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
|
||||
}
|
||||
return DeviceInfo(
|
||||
connections={(CONNECTION_NETWORK_MAC, self._mac)},
|
||||
identifiers={(DOMAIN, self._mac)},
|
||||
manufacturer="Gree",
|
||||
name=self._name,
|
||||
)
|
||||
|
|
|
@ -15,9 +15,6 @@ from homeassistant.components.sensor import (
|
|||
SensorEntityDescription,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_IDENTIFIERS,
|
||||
ATTR_MANUFACTURER,
|
||||
ATTR_NAME,
|
||||
CONF_NAME,
|
||||
CONF_PASSWORD,
|
||||
CONF_URL,
|
||||
|
@ -38,6 +35,7 @@ from homeassistant.const import (
|
|||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
)
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.util import Throttle, dt
|
||||
|
||||
from .const import (
|
||||
|
@ -979,11 +977,11 @@ class GrowattInverter(SensorEntity):
|
|||
self._attr_unique_id = unique_id
|
||||
self._attr_icon = "mdi:solar-power"
|
||||
|
||||
self._attr_device_info = {
|
||||
ATTR_IDENTIFIERS: {(DOMAIN, probe.device_id)},
|
||||
ATTR_NAME: name,
|
||||
ATTR_MANUFACTURER: "Growatt",
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, probe.device_id)},
|
||||
manufacturer="Growatt",
|
||||
name=name,
|
||||
)
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
|
|
|
@ -203,7 +203,7 @@ class GuardianEntity(CoordinatorEntity):
|
|||
self, entry: ConfigEntry, description: EntityDescription
|
||||
) -> None:
|
||||
"""Initialize."""
|
||||
self._attr_device_info = {"manufacturer": "Elexa"}
|
||||
self._attr_device_info = DeviceInfo(manufacturer="Elexa")
|
||||
self._attr_extra_state_attributes = {ATTR_ATTRIBUTION: "Data provided by Elexa"}
|
||||
self._entry = entry
|
||||
self.entity_description = description
|
||||
|
@ -258,11 +258,11 @@ class ValveControllerEntity(GuardianEntity):
|
|||
"""Initialize."""
|
||||
super().__init__(entry, description)
|
||||
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(DOMAIN, entry.data[CONF_UID])},
|
||||
"name": f"Guardian Valve Controller {entry.data[CONF_UID]}",
|
||||
"model": coordinators[API_SYSTEM_DIAGNOSTICS].data["firmware"],
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, entry.data[CONF_UID])},
|
||||
model=coordinators[API_SYSTEM_DIAGNOSTICS].data["firmware"],
|
||||
name=f"Guardian Valve Controller {entry.data[CONF_UID]}",
|
||||
)
|
||||
self._attr_name = f"Guardian {entry.data[CONF_UID]}: {description.name}"
|
||||
self._attr_unique_id = f"{entry.data[CONF_UID]}_{description.key}"
|
||||
self.coordinators = coordinators
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue