mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Use DeviceInfo on components with via_device (I-T) (#58212)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
6dd72869a6
commit
176ed4f7ba
@ -238,10 +238,10 @@ class AqualinkEntity(Entity):
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self.unique_id)},
|
||||
"name": self.name,
|
||||
"model": self.dev.__class__.__name__.replace("Aqualink", ""),
|
||||
"manufacturer": "Jandy",
|
||||
"via_device": (DOMAIN, self.dev.system.serial),
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.unique_id)},
|
||||
name=self.name,
|
||||
model=self.dev.__class__.__name__.replace("Aqualink", ""),
|
||||
manufacturer="Jandy",
|
||||
via_device=(DOMAIN, self.dev.system.serial),
|
||||
)
|
||||
|
@ -9,7 +9,7 @@ from homeassistant.helpers.dispatcher import (
|
||||
async_dispatcher_connect,
|
||||
async_dispatcher_send,
|
||||
)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
|
||||
from .const import (
|
||||
DOMAIN,
|
||||
@ -79,16 +79,16 @@ class InsteonEntity(Entity):
|
||||
return {"insteon_address": self.address, "insteon_group": self.group}
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, str(self._insteon_device.address))},
|
||||
"name": f"{self._insteon_device.description} {self._insteon_device.address}",
|
||||
"model": f"{self._insteon_device.model} ({self._insteon_device.cat!r}, 0x{self._insteon_device.subcat:02x})",
|
||||
"sw_version": f"{self._insteon_device.firmware:02x} Engine Version: {self._insteon_device.engine_version}",
|
||||
"manufacturer": "Smart Home",
|
||||
"via_device": (DOMAIN, str(devices.modem.address)),
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, str(self._insteon_device.address))},
|
||||
name=f"{self._insteon_device.description} {self._insteon_device.address}",
|
||||
model=f"{self._insteon_device.model} ({self._insteon_device.cat!r}, 0x{self._insteon_device.subcat:02x})",
|
||||
sw_version=f"{self._insteon_device.firmware:02x} Engine Version: {self._insteon_device.engine_version}",
|
||||
manufacturer="Smart Home",
|
||||
via_device=(DOMAIN, str(devices.modem.address)),
|
||||
)
|
||||
|
||||
@callback
|
||||
def async_entity_update(self, name, address, value, group):
|
||||
|
@ -35,6 +35,7 @@ from homeassistant.const import (
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import entity_platform
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.temperature import display_temp as show_temp
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
@ -483,13 +484,13 @@ class ZoneDevice(ClimateEntity):
|
||||
}
|
||||
self._supported_features |= SUPPORT_TARGET_TEMPERATURE
|
||||
|
||||
self._device_info = {
|
||||
"identifiers": {(IZONE, controller.unique_id, zone.index)},
|
||||
"name": self.name,
|
||||
"manufacturer": "IZone",
|
||||
"via_device": (IZONE, controller.unique_id),
|
||||
"model": zone.type.name.title(),
|
||||
}
|
||||
self._device_info = DeviceInfo(
|
||||
identifiers={(IZONE, controller.unique_id, zone.index)},
|
||||
name=self.name,
|
||||
manufacturer="IZone",
|
||||
via_device=(IZONE, controller.unique_id),
|
||||
model=zone.type.name.title(),
|
||||
)
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Call on adding to hass."""
|
||||
|
@ -17,7 +17,7 @@ from homeassistant.core import callback
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
|
||||
from .const import (
|
||||
ACTION_PRESS,
|
||||
@ -329,16 +329,16 @@ class LutronCasetaDevice(Entity):
|
||||
return str(self.serial)
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self.serial)},
|
||||
"name": self.name,
|
||||
"suggested_area": self._device["name"].split("_")[0],
|
||||
"manufacturer": MANUFACTURER,
|
||||
"model": f"{self._device['model']} ({self._device['type']})",
|
||||
"via_device": (DOMAIN, self._bridge_device["serial"]),
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self.serial)},
|
||||
name=self.name,
|
||||
suggested_area=self._device["name"].split("_")[0],
|
||||
manufacturer=MANUFACTURER,
|
||||
model=f"{self._device['model']} ({self._device['type']})",
|
||||
via_device=(DOMAIN, self._bridge_device["serial"]),
|
||||
)
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
|
@ -17,6 +17,7 @@ from homeassistant.components.cover import (
|
||||
CoverEntity,
|
||||
)
|
||||
from homeassistant.helpers import config_validation as cv, entity_platform
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import (
|
||||
@ -138,13 +139,13 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity):
|
||||
self._attr_device_class = device_class
|
||||
self._attr_name = f"{blind.blind_type}-{blind.mac[12:]}"
|
||||
self._attr_unique_id = blind.mac
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(DOMAIN, blind.mac)},
|
||||
"manufacturer": MANUFACTURER,
|
||||
"name": f"{blind.blind_type}-{blind.mac[12:]}",
|
||||
"model": blind.blind_type,
|
||||
"via_device": (DOMAIN, config_entry.unique_id),
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, blind.mac)},
|
||||
manufacturer=MANUFACTURER,
|
||||
name=f"{blind.blind_type}-{blind.mac[12:]}",
|
||||
model=blind.blind_type,
|
||||
via_device=(DOMAIN, config_entry.unique_id),
|
||||
)
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
|
@ -23,7 +23,7 @@ from homeassistant.helpers.dispatcher import (
|
||||
async_dispatcher_connect,
|
||||
async_dispatcher_send,
|
||||
)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
from homeassistant.helpers.typing import HomeAssistantType
|
||||
@ -273,14 +273,14 @@ class NetgearDeviceEntity(Entity):
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device information."""
|
||||
return {
|
||||
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
|
||||
"default_name": self._device_name,
|
||||
"default_model": self._device["device_model"],
|
||||
"via_device": (DOMAIN, self._router.unique_id),
|
||||
}
|
||||
return DeviceInfo(
|
||||
connections={(CONNECTION_NETWORK_MAC, self._mac)},
|
||||
default_name=self._device_name,
|
||||
default_model=self._device["device_model"],
|
||||
via_device=(DOMAIN, self._router.unique_id),
|
||||
)
|
||||
|
||||
@property
|
||||
def should_poll(self) -> bool:
|
||||
|
@ -17,7 +17,7 @@ from homeassistant.helpers import (
|
||||
config_validation as cv,
|
||||
device_registry as dr,
|
||||
)
|
||||
from homeassistant.helpers.entity import EntityDescription
|
||||
from homeassistant.helpers.entity import DeviceInfo, EntityDescription
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
CoordinatorEntity,
|
||||
DataUpdateCoordinator,
|
||||
@ -147,14 +147,14 @@ class NotionEntity(CoordinatorEntity):
|
||||
|
||||
bridge = self.coordinator.data["bridges"].get(bridge_id, {})
|
||||
sensor = self.coordinator.data["sensors"][sensor_id]
|
||||
self._attr_device_info = {
|
||||
"identifiers": {(DOMAIN, sensor["hardware_id"])},
|
||||
"manufacturer": "Silicon Labs",
|
||||
"model": sensor["hardware_revision"],
|
||||
"name": str(sensor["name"]),
|
||||
"sw_version": sensor["firmware_version"],
|
||||
"via_device": (DOMAIN, bridge.get("hardware_id")),
|
||||
}
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, sensor["hardware_id"])},
|
||||
manufacturer="Silicon Labs",
|
||||
model=sensor["hardware_revision"],
|
||||
name=str(sensor["name"]),
|
||||
sw_version=sensor["firmware_version"],
|
||||
via_device=(DOMAIN, bridge.get("hardware_id")),
|
||||
)
|
||||
|
||||
self._attr_extra_state_attributes = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
|
||||
self._attr_name = f'{sensor["name"]}: {description.name}'
|
||||
|
@ -27,6 +27,7 @@ from homeassistant.helpers.dispatcher import (
|
||||
async_dispatcher_connect,
|
||||
async_dispatcher_send,
|
||||
)
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_registry import async_get_registry
|
||||
from homeassistant.helpers.network import is_internal_request
|
||||
|
||||
@ -523,28 +524,28 @@ class PlexMediaPlayer(MediaPlayerEntity):
|
||||
return attributes
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return a device description for device registry."""
|
||||
if self.machine_identifier is None:
|
||||
return None
|
||||
|
||||
if self.device_product in TRANSIENT_DEVICE_MODELS:
|
||||
return {
|
||||
"identifiers": {(PLEX_DOMAIN, "plex.tv-clients")},
|
||||
"name": "Plex Client Service",
|
||||
"manufacturer": "Plex",
|
||||
"model": "Plex Clients",
|
||||
"entry_type": "service",
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(PLEX_DOMAIN, "plex.tv-clients")},
|
||||
name="Plex Client Service",
|
||||
manufacturer="Plex",
|
||||
model="Plex Clients",
|
||||
entry_type="service",
|
||||
)
|
||||
|
||||
return {
|
||||
"identifiers": {(PLEX_DOMAIN, self.machine_identifier)},
|
||||
"manufacturer": self.device_platform or "Plex",
|
||||
"model": self.device_product or self.device_make,
|
||||
"name": self.name,
|
||||
"sw_version": self.device_version,
|
||||
"via_device": (PLEX_DOMAIN, self.plex_server.machine_identifier),
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(PLEX_DOMAIN, self.machine_identifier)},
|
||||
manufacturer=self.device_platform or "Plex",
|
||||
model=self.device_product or self.device_make,
|
||||
name=self.name,
|
||||
sw_version=self.device_version,
|
||||
via_device=(PLEX_DOMAIN, self.plex_server.machine_identifier),
|
||||
)
|
||||
|
||||
async def async_browse_media(self, media_content_type=None, media_content_id=None):
|
||||
"""Implement the websocket media browsing helper."""
|
||||
|
@ -21,7 +21,7 @@ from homeassistant.helpers.dispatcher import (
|
||||
async_dispatcher_connect,
|
||||
async_dispatcher_send,
|
||||
)
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
from homeassistant.util.dt import as_local, parse_datetime, utc_from_timestamp
|
||||
|
||||
@ -308,20 +308,20 @@ class MinutPointEntity(Entity):
|
||||
return attrs
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return a device description for device registry."""
|
||||
device = self.device.device
|
||||
return {
|
||||
"connections": {
|
||||
return DeviceInfo(
|
||||
connections={
|
||||
(device_registry.CONNECTION_NETWORK_MAC, device["device_mac"])
|
||||
},
|
||||
"identifieres": device["device_id"],
|
||||
"manufacturer": "Minut",
|
||||
"model": f"Point v{device['hardware_version']}",
|
||||
"name": device["description"],
|
||||
"sw_version": device["firmware"]["installed"],
|
||||
"via_device": (DOMAIN, device["home"]),
|
||||
}
|
||||
identifieres=device["device_id"],
|
||||
manufacturer="Minut",
|
||||
model=f"Point v{device['hardware_version']}",
|
||||
name=device["description"],
|
||||
sw_version=device["firmware"]["installed"],
|
||||
via_device=(DOMAIN, device["home"]),
|
||||
)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@ -109,14 +109,14 @@ class TradfriBaseDevice(TradfriBaseClass):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device info."""
|
||||
info = self._device.device_info
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._device.id)},
|
||||
"manufacturer": info.manufacturer,
|
||||
"model": info.model_number,
|
||||
"name": self._attr_name,
|
||||
"sw_version": info.firmware_version,
|
||||
"via_device": (DOMAIN, self._gateway_id),
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._device.id)},
|
||||
manufacturer=info.manufacturer,
|
||||
model=info.model_number,
|
||||
name=self._attr_name,
|
||||
sw_version=info.firmware_version,
|
||||
via_device=(DOMAIN, self._gateway_id),
|
||||
)
|
||||
|
||||
def _refresh(self, device: Device) -> None:
|
||||
"""Refresh the device data."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user