mirror of https://github.com/home-assistant/core
Use DeviceInfo Class P-R (#58324)
This commit is contained in:
parent
5642350070
commit
7ccfaed736
|
@ -9,7 +9,6 @@ DOMAIN: Final = "p1_monitor"
|
|||
LOGGER = logging.getLogger(__package__)
|
||||
SCAN_INTERVAL = timedelta(seconds=5)
|
||||
|
||||
ATTR_ENTRY_TYPE: Final = "entry_type"
|
||||
ENTRY_TYPE_SERVICE: Final = "service"
|
||||
|
||||
SERVICE_SMARTMETER: Final = "smartmeter"
|
||||
|
|
|
@ -12,9 +12,6 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ATTR_IDENTIFIERS,
|
||||
ATTR_MANUFACTURER,
|
||||
ATTR_NAME,
|
||||
CURRENCY_EURO,
|
||||
DEVICE_CLASS_CURRENT,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
|
@ -28,13 +25,13 @@ from homeassistant.const import (
|
|||
VOLUME_CUBIC_METERS,
|
||||
)
|
||||
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
|
||||
|
||||
from . import P1MonitorDataUpdateCoordinator
|
||||
from .const import (
|
||||
ATTR_ENTRY_TYPE,
|
||||
DOMAIN,
|
||||
ENTRY_TYPE_SERVICE,
|
||||
SERVICE_PHASES,
|
||||
|
@ -266,14 +263,14 @@ class P1MonitorSensorEntity(CoordinatorEntity, SensorEntity):
|
|||
f"{coordinator.config_entry.entry_id}_{service_key}_{description.key}"
|
||||
)
|
||||
|
||||
self._attr_device_info = {
|
||||
ATTR_IDENTIFIERS: {
|
||||
self._attr_device_info = DeviceInfo(
|
||||
entry_type=ENTRY_TYPE_SERVICE,
|
||||
identifiers={
|
||||
(DOMAIN, f"{coordinator.config_entry.entry_id}_{service_key}")
|
||||
},
|
||||
ATTR_NAME: service,
|
||||
ATTR_MANUFACTURER: "P1 Monitor",
|
||||
ATTR_ENTRY_TYPE: ENTRY_TYPE_SERVICE,
|
||||
}
|
||||
manufacturer="P1 Monitor",
|
||||
name=service,
|
||||
)
|
||||
|
||||
@property
|
||||
def native_value(self) -> StateType:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
"""Media player support for Panasonic Viera TV."""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from panasonic_viera import Keys
|
||||
|
@ -19,6 +21,7 @@ from homeassistant.components.media_player.const import (
|
|||
SUPPORT_VOLUME_STEP,
|
||||
)
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from .const import (
|
||||
ATTR_DEVICE_INFO,
|
||||
|
@ -78,18 +81,16 @@ class PanasonicVieraTVEntity(MediaPlayerEntity):
|
|||
return self._device_info[ATTR_UDN]
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo | None:
|
||||
"""Return device specific attributes."""
|
||||
if self._device_info is None:
|
||||
return None
|
||||
return {
|
||||
"name": self._name,
|
||||
"identifiers": {(DOMAIN, self._device_info[ATTR_UDN])},
|
||||
"manufacturer": self._device_info.get(
|
||||
ATTR_MANUFACTURER, DEFAULT_MANUFACTURER
|
||||
),
|
||||
"model": self._device_info.get(ATTR_MODEL_NUMBER, DEFAULT_MODEL_NUMBER),
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._device_info[ATTR_UDN])},
|
||||
manufacturer=self._device_info.get(ATTR_MANUFACTURER, DEFAULT_MANUFACTURER),
|
||||
model=self._device_info.get(ATTR_MODEL_NUMBER, DEFAULT_MODEL_NUMBER),
|
||||
name=self._name,
|
||||
)
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
"""Remote control support for Panasonic Viera TV."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.remote import RemoteEntity
|
||||
from homeassistant.const import CONF_NAME, STATE_ON
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from .const import (
|
||||
ATTR_DEVICE_INFO,
|
||||
|
@ -44,18 +47,16 @@ class PanasonicVieraRemoteEntity(RemoteEntity):
|
|||
return self._device_info[ATTR_UDN]
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo | None:
|
||||
"""Return device specific attributes."""
|
||||
if self._device_info is None:
|
||||
return None
|
||||
return {
|
||||
"name": self._name,
|
||||
"identifiers": {(DOMAIN, self._device_info[ATTR_UDN])},
|
||||
"manufacturer": self._device_info.get(
|
||||
ATTR_MANUFACTURER, DEFAULT_MANUFACTURER
|
||||
),
|
||||
"model": self._device_info.get(ATTR_MODEL_NUMBER, DEFAULT_MODEL_NUMBER),
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._device_info[ATTR_UDN])},
|
||||
manufacturer=self._device_info.get(ATTR_MANUFACTURER, DEFAULT_MANUFACTURER),
|
||||
model=self._device_info.get(ATTR_MODEL_NUMBER, DEFAULT_MODEL_NUMBER),
|
||||
name=self._name,
|
||||
)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
|
@ -19,6 +19,7 @@ from homeassistant.components.light import (
|
|||
LightEntity,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
from homeassistant.util.color import color_hsv_to_RGB, color_RGB_to_hsv
|
||||
|
||||
|
@ -154,15 +155,15 @@ class PhilipsTVLightEntity(CoordinatorEntity, LightEntity):
|
|||
self._attr_name = self._system["name"]
|
||||
self._attr_unique_id = unique_id
|
||||
self._attr_icon = "mdi:television-ambient-light"
|
||||
self._attr_device_info = {
|
||||
"name": self._system["name"],
|
||||
"identifiers": {
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, self._attr_unique_id),
|
||||
},
|
||||
"model": self._system.get("model"),
|
||||
"manufacturer": "Philips",
|
||||
"sw_version": self._system.get("softwareversion"),
|
||||
}
|
||||
manufacturer="Philips",
|
||||
model=self._system.get("model"),
|
||||
name=self._system["name"],
|
||||
sw_version=self._system.get("softwareversion"),
|
||||
)
|
||||
|
||||
self._update_from_coordinator()
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from . import LOGGER as _LOGGER, PhilipsTVDataUpdateCoordinator
|
||||
|
@ -324,17 +325,17 @@ class PhilipsTVMediaPlayer(CoordinatorEntity, MediaPlayerEntity):
|
|||
return self._unique_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return a device description for device registry."""
|
||||
return {
|
||||
"name": self._system["name"],
|
||||
"identifiers": {
|
||||
return DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, self._unique_id),
|
||||
},
|
||||
"model": self._system.get("model"),
|
||||
"manufacturer": "Philips",
|
||||
"sw_version": self._system.get("softwareversion"),
|
||||
}
|
||||
manufacturer="Philips",
|
||||
model=self._system.get("model"),
|
||||
sw_version=self._system.get("softwareversion"),
|
||||
name=self._system["name"],
|
||||
)
|
||||
|
||||
async def async_play_media(self, media_type, media_id, **kwargs):
|
||||
"""Play a piece of media."""
|
||||
|
|
|
@ -10,6 +10,7 @@ from homeassistant.components.remote import (
|
|||
DEFAULT_DELAY_SECS,
|
||||
RemoteEntity,
|
||||
)
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from . import LOGGER, PhilipsTVDataUpdateCoordinator
|
||||
from .const import CONF_SYSTEM, DOMAIN
|
||||
|
@ -67,17 +68,17 @@ class PhilipsTVRemote(RemoteEntity):
|
|||
return self._unique_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return a device description for device registry."""
|
||||
return {
|
||||
"name": self._system["name"],
|
||||
"identifiers": {
|
||||
return DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, self._unique_id),
|
||||
},
|
||||
"model": self._system.get("model"),
|
||||
"manufacturer": "Philips",
|
||||
"sw_version": self._system.get("softwareversion"),
|
||||
}
|
||||
manufacturer="Philips",
|
||||
model=self._system.get("model"),
|
||||
name=self._system["name"],
|
||||
sw_version=self._system.get("softwareversion"),
|
||||
)
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
"""Turn the device on."""
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
"""Definition of Picnic sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
from typing import Any, cast
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.typing import StateType
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
|
@ -75,15 +76,15 @@ class PicnicSensor(SensorEntity, CoordinatorEntity):
|
|||
return self.coordinator.last_update_success and self.state is not None
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._service_unique_id)},
|
||||
"manufacturer": "Picnic",
|
||||
"model": self._service_unique_id,
|
||||
"name": f"Picnic: {self.coordinator.data[ADDRESS]}",
|
||||
"entry_type": "service",
|
||||
}
|
||||
return DeviceInfo(
|
||||
entry_type="service",
|
||||
identifiers={(DOMAIN, cast(str, self._service_unique_id))},
|
||||
manufacturer="Picnic",
|
||||
model=self._service_unique_id,
|
||||
name=f"Picnic: {self.coordinator.data[ADDRESS]}",
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _to_capitalized_name(name: str) -> str:
|
||||
|
|
|
@ -53,19 +53,16 @@ class PlaatoEntity(entity.Entity):
|
|||
return f"{self._device_id}_{self._sensor_type}"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> entity.DeviceInfo:
|
||||
"""Get device info."""
|
||||
device_info = {
|
||||
"identifiers": {(DOMAIN, self._device_id)},
|
||||
"name": self._device_name,
|
||||
"manufacturer": "Plaato",
|
||||
"model": self._device_type,
|
||||
}
|
||||
|
||||
if self._sensor_data.firmware_version != "":
|
||||
device_info["sw_version"] = self._sensor_data.firmware_version
|
||||
|
||||
return device_info
|
||||
sw_version = self._sensor_data.firmware_version
|
||||
return entity.DeviceInfo(
|
||||
identifiers={(DOMAIN, self._device_id)},
|
||||
manufacturer="Plaato",
|
||||
model=self._device_type,
|
||||
name=self._device_name,
|
||||
sw_version=sw_version if sw_version != "" else None,
|
||||
)
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
|
|
|
@ -15,6 +15,7 @@ from homeassistant.components.light import (
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
import homeassistant.util.color as color_util
|
||||
|
||||
|
@ -94,14 +95,14 @@ class PlumLight(LightEntity):
|
|||
return self._load.name
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
return {
|
||||
"name": self.name,
|
||||
"identifiers": {(DOMAIN, self.unique_id)},
|
||||
"model": "Dimmer",
|
||||
"manufacturer": "Plum",
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.unique_id)},
|
||||
manufacturer="Plum",
|
||||
model="Dimmer",
|
||||
name=self.name,
|
||||
)
|
||||
|
||||
@property
|
||||
def brightness(self) -> int:
|
||||
|
@ -185,14 +186,14 @@ class GlowRing(LightEntity):
|
|||
return self._name
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
return {
|
||||
"name": self.name,
|
||||
"identifiers": {(DOMAIN, self.unique_id)},
|
||||
"model": "Glow Ring",
|
||||
"manufacturer": "Plum",
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.unique_id)},
|
||||
manufacturer="Plum",
|
||||
model="Glow Ring",
|
||||
name=self.name,
|
||||
)
|
||||
|
||||
@property
|
||||
def brightness(self) -> int:
|
||||
|
|
|
@ -315,7 +315,7 @@ class MinutPointEntity(Entity):
|
|||
connections={
|
||||
(device_registry.CONNECTION_NETWORK_MAC, device["device_mac"])
|
||||
},
|
||||
identifieres=device["device_id"],
|
||||
identifiers=device["device_id"],
|
||||
manufacturer="Minut",
|
||||
model=f"Point v{device['hardware_version']}",
|
||||
name=device["description"],
|
||||
|
|
|
@ -10,6 +10,7 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from .const import DOMAIN as POINT_DOMAIN, POINT_DISCOVERY_NEW, SIGNAL_WEBHOOK
|
||||
|
||||
|
@ -117,10 +118,10 @@ class MinutPointAlarmControl(AlarmControlPanelEntity):
|
|||
return f"point.{self._home_id}"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return a device description for device registry."""
|
||||
return {
|
||||
"identifiers": {(POINT_DOMAIN, self._home_id)},
|
||||
"name": self.name,
|
||||
"manufacturer": "Minut",
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(POINT_DOMAIN, self._home_id)},
|
||||
manufacturer="Minut",
|
||||
name=self.name,
|
||||
)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""The Tesla Powerwall integration base entity."""
|
||||
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN, MANUFACTURER, MODEL
|
||||
|
@ -20,15 +21,12 @@ class PowerWallEntity(CoordinatorEntity):
|
|||
self.base_unique_id = "_".join(powerwalls_serial_numbers)
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Powerwall device info."""
|
||||
device_info = {
|
||||
"identifiers": {(DOMAIN, self.base_unique_id)},
|
||||
"name": self._site_info.site_name,
|
||||
"manufacturer": MANUFACTURER,
|
||||
}
|
||||
model = MODEL
|
||||
model += f" ({self._device_type.name})"
|
||||
device_info["model"] = model
|
||||
device_info["sw_version"] = self._version
|
||||
return device_info
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.base_unique_id)},
|
||||
manufacturer=MANUFACTURER,
|
||||
model=f"{MODEL} ({self._device_type.name})",
|
||||
name=self._site_info.site_name,
|
||||
sw_version=self._version,
|
||||
)
|
||||
|
|
|
@ -32,6 +32,7 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import device_registry, entity_registry
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from .const import (
|
||||
ATTR_MEDIA_IMAGE_URL,
|
||||
|
@ -92,7 +93,6 @@ class PS4Device(MediaPlayerEntity):
|
|||
self._source_list = []
|
||||
self._retry = 0
|
||||
self._disconnected = False
|
||||
self._info = None
|
||||
self._unique_id = None
|
||||
|
||||
@callback
|
||||
|
@ -150,7 +150,7 @@ class PS4Device(MediaPlayerEntity):
|
|||
if self._ps4.ddp_protocol is None:
|
||||
# Use socket.socket.
|
||||
await self.hass.async_add_executor_job(self._ps4.get_status)
|
||||
if self._info is None:
|
||||
if self._attr_device_info is None:
|
||||
# Add entity to registry.
|
||||
await self.async_get_device_info(self._ps4.status)
|
||||
self._ps4.ddp_protocol = self.hass.data[PS4_DATA].protocol
|
||||
|
@ -337,26 +337,26 @@ class PS4Device(MediaPlayerEntity):
|
|||
break
|
||||
for device in d_registry.devices.values():
|
||||
if self._entry_id in device.config_entries:
|
||||
self._info = {
|
||||
"name": device.name,
|
||||
"model": device.model,
|
||||
"identifiers": device.identifiers,
|
||||
"manufacturer": device.manufacturer,
|
||||
"sw_version": device.sw_version,
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers=device.identifiers,
|
||||
manufacturer=device.manufacturer,
|
||||
model=device.model,
|
||||
name=device.name,
|
||||
sw_version=device.sw_version,
|
||||
)
|
||||
break
|
||||
|
||||
else:
|
||||
_sw_version = status["system-version"]
|
||||
_sw_version = _sw_version[1:4]
|
||||
sw_version = f"{_sw_version[0]}.{_sw_version[1:]}"
|
||||
self._info = {
|
||||
"name": status["host-name"],
|
||||
"model": "PlayStation 4",
|
||||
"identifiers": {(PS4_DOMAIN, status["host-id"])},
|
||||
"manufacturer": "Sony Interactive Entertainment Inc.",
|
||||
"sw_version": sw_version,
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(PS4_DOMAIN, status["host-id"])},
|
||||
manufacturer="Sony Interactive Entertainment Inc.",
|
||||
model="PlayStation 4",
|
||||
name=status["host-name"],
|
||||
sw_version=sw_version,
|
||||
)
|
||||
|
||||
self._unique_id = format_unique_id(self._creds, status["host-id"])
|
||||
|
||||
|
@ -368,11 +368,6 @@ class PS4Device(MediaPlayerEntity):
|
|||
self.unsubscribe_to_protocol()
|
||||
self.hass.data[PS4_DATA].devices.remove(self)
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
"""Return information about the device."""
|
||||
return self._info
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return Unique ID for entity."""
|
||||
|
|
|
@ -98,11 +98,11 @@ class EagleSensor(CoordinatorEntity, SensorEntity):
|
|||
return self.coordinator.data.get(self.entity_description.key)
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo | None:
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info."""
|
||||
return {
|
||||
"name": self.coordinator.model,
|
||||
"identifiers": {(DOMAIN, self.coordinator.cloud_id)},
|
||||
"manufacturer": "Rainforest Automation",
|
||||
"model": self.coordinator.model,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.coordinator.cloud_id)},
|
||||
manufacturer="Rainforest Automation",
|
||||
model=self.coordinator.model,
|
||||
name=self.coordinator.model,
|
||||
)
|
||||
|
|
|
@ -11,13 +11,6 @@ from typing import cast
|
|||
from renault_api.kamereon import models
|
||||
from renault_api.renault_vehicle import RenaultVehicle
|
||||
|
||||
from homeassistant.const import (
|
||||
ATTR_IDENTIFIERS,
|
||||
ATTR_MANUFACTURER,
|
||||
ATTR_MODEL,
|
||||
ATTR_NAME,
|
||||
ATTR_SW_VERSION,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
|
@ -55,13 +48,13 @@ class RenaultVehicleProxy:
|
|||
self.hass = hass
|
||||
self._vehicle = vehicle
|
||||
self._details = details
|
||||
self._device_info: DeviceInfo = {
|
||||
ATTR_IDENTIFIERS: {(DOMAIN, cast(str, details.vin))},
|
||||
ATTR_MANUFACTURER: (details.get_brand_label() or "").capitalize(),
|
||||
ATTR_MODEL: (details.get_model_label() or "").capitalize(),
|
||||
ATTR_NAME: details.registrationNumber or "",
|
||||
ATTR_SW_VERSION: details.get_model_code() or "",
|
||||
}
|
||||
self._device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, cast(str, details.vin))},
|
||||
manufacturer=(details.get_brand_label() or "").capitalize(),
|
||||
model=(details.get_model_label() or "").capitalize(),
|
||||
name=details.registrationNumber or "",
|
||||
sw_version=details.get_model_code() or "",
|
||||
)
|
||||
self.coordinators: dict[str, RenaultDataUpdateCoordinator] = {}
|
||||
self.hvac_target_temperature = 21
|
||||
self._scan_interval = scan_interval
|
||||
|
|
|
@ -22,6 +22,7 @@ from homeassistant.const import (
|
|||
from homeassistant.core import callback
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.device_registry import DeviceRegistry
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.restore_state import RestoreEntity
|
||||
|
||||
from .const import (
|
||||
|
@ -393,11 +394,11 @@ class RfxtrxEntity(RestoreEntity):
|
|||
@property
|
||||
def device_info(self):
|
||||
"""Return the device info."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, *self._device_id)},
|
||||
"name": f"{self._device.type_string} {self._device.id_string}",
|
||||
"model": self._device.type_string,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, *self._device_id)},
|
||||
model=self._device.type_string,
|
||||
name=f"{self._device.type_string} {self._device.id_string}",
|
||||
)
|
||||
|
||||
def _event_applies(self, event, device_id):
|
||||
"""Check if event applies to me."""
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"""Base class for Ring entity."""
|
||||
from homeassistant.const import ATTR_ATTRIBUTION
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from . import ATTRIBUTION, DOMAIN
|
||||
|
||||
|
@ -43,11 +44,11 @@ class RingEntityMixin:
|
|||
return {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device info."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._device.device_id)},
|
||||
"name": self._device.name,
|
||||
"model": self._device.model,
|
||||
"manufacturer": "Ring",
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._device.device_id)},
|
||||
manufacturer="Ring",
|
||||
model=self._device.model,
|
||||
name=self._device.name,
|
||||
)
|
||||
|
|
|
@ -4,6 +4,7 @@ from homeassistant.components.binary_sensor import (
|
|||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.helpers import entity_platform
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
||||
from .const import DATA_COORDINATOR, DOMAIN
|
||||
from .entity import RiscoEntity, binary_sensor_unique_id
|
||||
|
@ -41,13 +42,13 @@ class RiscoBinarySensor(BinarySensorEntity, RiscoEntity):
|
|||
self._zone = self.coordinator.data.zones[self._zone_id]
|
||||
|
||||
@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": "Risco",
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.unique_id)},
|
||||
manufacturer="Risco",
|
||||
name=self.name,
|
||||
)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from pyrituals import Diffuser
|
||||
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from . import RitualsDataUpdateCoordinator
|
||||
|
@ -33,13 +34,13 @@ class DiffuserEntity(CoordinatorEntity):
|
|||
|
||||
self._attr_name = f"{hubname}{entity_suffix}"
|
||||
self._attr_unique_id = f"{hublot}{entity_suffix}"
|
||||
self._attr_device_info = {
|
||||
"name": hubname,
|
||||
"identifiers": {(DOMAIN, hublot)},
|
||||
"manufacturer": MANUFACTURER,
|
||||
"model": MODEL if diffuser.has_battery else MODEL2,
|
||||
"sw_version": diffuser.version,
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, hublot)},
|
||||
manufacturer=MANUFACTURER,
|
||||
model=MODEL if diffuser.has_battery else MODEL2,
|
||||
name=hubname,
|
||||
sw_version=diffuser.version,
|
||||
)
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
|
|
|
@ -24,7 +24,7 @@ from homeassistant.components.vacuum import (
|
|||
StateVacuumEntity,
|
||||
)
|
||||
import homeassistant.helpers.device_registry as dr
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from . import roomba_reported_state
|
||||
|
@ -96,18 +96,19 @@ class IRobotEntity(Entity):
|
|||
@property
|
||||
def device_info(self):
|
||||
"""Return the device info of the vacuum cleaner."""
|
||||
info = {
|
||||
"identifiers": {(DOMAIN, self.robot_unique_id)},
|
||||
"manufacturer": "iRobot",
|
||||
"name": str(self._name),
|
||||
"sw_version": self._version,
|
||||
"model": self._sku,
|
||||
}
|
||||
connections = None
|
||||
if mac_address := self.vacuum_state.get("hwPartsRev", {}).get(
|
||||
"wlan0HwAddr", self.vacuum_state.get("mac")
|
||||
):
|
||||
info["connections"] = {(dr.CONNECTION_NETWORK_MAC, mac_address)}
|
||||
return info
|
||||
connections = {(dr.CONNECTION_NETWORK_MAC, mac_address)}
|
||||
return DeviceInfo(
|
||||
connections=connections,
|
||||
identifiers={(DOMAIN, self.robot_unique_id)},
|
||||
manufacturer="iRobot",
|
||||
model=self._sku,
|
||||
name=str(self._name),
|
||||
sw_version=self._version,
|
||||
)
|
||||
|
||||
@property
|
||||
def _battery_level(self):
|
||||
|
|
|
@ -163,7 +163,6 @@ class RoonDevice(MediaPlayerEntity):
|
|||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
dev_model = "player"
|
||||
if self.player_data.get("source_controls"):
|
||||
dev_model = self.player_data["source_controls"][0].get("display_name")
|
||||
return DeviceInfo(
|
||||
|
|
Loading…
Reference in New Issue