Use DeviceInfo Class H (#58276)
This commit is contained in:
parent
f176dc512c
commit
4a8e9df026
25 changed files with 110 additions and 103 deletions
|
@ -10,6 +10,7 @@ import aioharmony.exceptions as aioexc
|
||||||
from aioharmony.harmonyapi import HarmonyAPI as HarmonyClient
|
from aioharmony.harmonyapi import HarmonyAPI as HarmonyClient
|
||||||
|
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
|
||||||
from .const import ACTIVITY_POWER_OFF
|
from .const import ACTIVITY_POWER_OFF
|
||||||
from .subscriber import HarmonySubscriberMixin
|
from .subscriber import HarmonySubscriberMixin
|
||||||
|
@ -82,20 +83,20 @@ class HarmonyData(HarmonySubscriberMixin):
|
||||||
"""Return the current activity tuple."""
|
"""Return the current activity tuple."""
|
||||||
return self._client.current_activity
|
return self._client.current_activity
|
||||||
|
|
||||||
def device_info(self, domain: str):
|
def device_info(self, domain: str) -> DeviceInfo:
|
||||||
"""Return hub device info."""
|
"""Return hub device info."""
|
||||||
model = "Harmony Hub"
|
model = "Harmony Hub"
|
||||||
if "ethernetStatus" in self._client.hub_config.info:
|
if "ethernetStatus" in self._client.hub_config.info:
|
||||||
model = "Harmony Hub Pro 2400"
|
model = "Harmony Hub Pro 2400"
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(domain, self.unique_id)},
|
identifiers={(domain, self.unique_id)},
|
||||||
"manufacturer": "Logitech",
|
manufacturer="Logitech",
|
||||||
"sw_version": self._client.hub_config.info.get(
|
model=model,
|
||||||
|
name=self.name,
|
||||||
|
sw_version=self._client.hub_config.info.get(
|
||||||
"hubSwVersion", self._client.fw_version
|
"hubSwVersion", self._client.fw_version
|
||||||
),
|
),
|
||||||
"name": self.name,
|
)
|
||||||
"model": model,
|
|
||||||
}
|
|
||||||
|
|
||||||
async def connect(self) -> bool:
|
async def connect(self) -> bool:
|
||||||
"""Connect to the Harmony Hub."""
|
"""Connect to the Harmony Hub."""
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.const import ATTR_NAME
|
from homeassistant.const import ATTR_NAME
|
||||||
from homeassistant.helpers.entity import EntityDescription
|
from homeassistant.helpers.entity import DeviceInfo, EntityDescription
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from . import DOMAIN, HassioDataUpdateCoordinator
|
from . import DOMAIN, HassioDataUpdateCoordinator
|
||||||
|
@ -26,7 +26,7 @@ class HassioAddonEntity(CoordinatorEntity):
|
||||||
self._addon_slug = addon[ATTR_SLUG]
|
self._addon_slug = addon[ATTR_SLUG]
|
||||||
self._attr_name = f"{addon[ATTR_NAME]}: {entity_description.name}"
|
self._attr_name = f"{addon[ATTR_NAME]}: {entity_description.name}"
|
||||||
self._attr_unique_id = f"{addon[ATTR_SLUG]}_{entity_description.key}"
|
self._attr_unique_id = f"{addon[ATTR_SLUG]}_{entity_description.key}"
|
||||||
self._attr_device_info = {"identifiers": {(DOMAIN, addon[ATTR_SLUG])}}
|
self._attr_device_info = DeviceInfo(identifiers={(DOMAIN, addon[ATTR_SLUG])})
|
||||||
|
|
||||||
|
|
||||||
class HassioOSEntity(CoordinatorEntity):
|
class HassioOSEntity(CoordinatorEntity):
|
||||||
|
@ -42,4 +42,4 @@ class HassioOSEntity(CoordinatorEntity):
|
||||||
self.entity_description = entity_description
|
self.entity_description = entity_description
|
||||||
self._attr_name = f"Home Assistant Operating System: {entity_description.name}"
|
self._attr_name = f"Home Assistant Operating System: {entity_description.name}"
|
||||||
self._attr_unique_id = f"home_assistant_os_{entity_description.key}"
|
self._attr_unique_id = f"home_assistant_os_{entity_description.key}"
|
||||||
self._attr_device_info = {"identifiers": {(DOMAIN, "OS")}}
|
self._attr_device_info = DeviceInfo(identifiers={(DOMAIN, "OS")})
|
||||||
|
|
|
@ -255,13 +255,13 @@ class HeosMediaPlayer(MediaPlayerEntity):
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Get attributes about the device."""
|
"""Get attributes about the device."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(HEOS_DOMAIN, self._player.player_id)},
|
identifiers={(HEOS_DOMAIN, self._player.player_id)},
|
||||||
"name": self._player.name,
|
manufacturer="HEOS",
|
||||||
"model": self._player.model,
|
model=self._player.model,
|
||||||
"manufacturer": "HEOS",
|
name=self._player.name,
|
||||||
"sw_version": self._player.version,
|
sw_version=self._player.version,
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict:
|
def extra_state_attributes(self) -> dict:
|
||||||
|
|
|
@ -51,9 +51,9 @@ class HiveBinarySensorEntity(HiveEntity, BinarySensorEntity):
|
||||||
"""Return device information."""
|
"""Return device information."""
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self.device["device_id"])},
|
identifiers={(DOMAIN, self.device["device_id"])},
|
||||||
name=self.device["device_name"],
|
|
||||||
model=self.device["deviceData"]["model"],
|
|
||||||
manufacturer=self.device["deviceData"]["manufacturer"],
|
manufacturer=self.device["deviceData"]["manufacturer"],
|
||||||
|
model=self.device["deviceData"]["model"],
|
||||||
|
name=self.device["device_name"],
|
||||||
sw_version=self.device["deviceData"]["version"],
|
sw_version=self.device["deviceData"]["version"],
|
||||||
via_device=(DOMAIN, self.device["parentDevice"]),
|
via_device=(DOMAIN, self.device["parentDevice"]),
|
||||||
)
|
)
|
||||||
|
|
|
@ -122,9 +122,9 @@ class HiveClimateEntity(HiveEntity, ClimateEntity):
|
||||||
"""Return device information."""
|
"""Return device information."""
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self.device["device_id"])},
|
identifiers={(DOMAIN, self.device["device_id"])},
|
||||||
name=self.device["device_name"],
|
|
||||||
model=self.device["deviceData"]["model"],
|
|
||||||
manufacturer=self.device["deviceData"]["manufacturer"],
|
manufacturer=self.device["deviceData"]["manufacturer"],
|
||||||
|
model=self.device["deviceData"]["model"],
|
||||||
|
name=self.device["device_name"],
|
||||||
sw_version=self.device["deviceData"]["version"],
|
sw_version=self.device["deviceData"]["version"],
|
||||||
via_device=(DOMAIN, self.device["parentDevice"]),
|
via_device=(DOMAIN, self.device["parentDevice"]),
|
||||||
)
|
)
|
||||||
|
|
|
@ -45,9 +45,9 @@ class HiveDeviceLight(HiveEntity, LightEntity):
|
||||||
"""Return device information."""
|
"""Return device information."""
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self.device["device_id"])},
|
identifiers={(DOMAIN, self.device["device_id"])},
|
||||||
name=self.device["device_name"],
|
|
||||||
model=self.device["deviceData"]["model"],
|
|
||||||
manufacturer=self.device["deviceData"]["manufacturer"],
|
manufacturer=self.device["deviceData"]["manufacturer"],
|
||||||
|
model=self.device["deviceData"]["model"],
|
||||||
|
name=self.device["device_name"],
|
||||||
sw_version=self.device["deviceData"]["version"],
|
sw_version=self.device["deviceData"]["version"],
|
||||||
via_device=(DOMAIN, self.device["parentDevice"]),
|
via_device=(DOMAIN, self.device["parentDevice"]),
|
||||||
)
|
)
|
||||||
|
|
|
@ -40,9 +40,9 @@ class HiveSensorEntity(HiveEntity, SensorEntity):
|
||||||
"""Return device information."""
|
"""Return device information."""
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self.device["device_id"])},
|
identifiers={(DOMAIN, self.device["device_id"])},
|
||||||
name=self.device["device_name"],
|
|
||||||
model=self.device["deviceData"]["model"],
|
|
||||||
manufacturer=self.device["deviceData"]["manufacturer"],
|
manufacturer=self.device["deviceData"]["manufacturer"],
|
||||||
|
model=self.device["deviceData"]["model"],
|
||||||
|
name=self.device["device_name"],
|
||||||
sw_version=self.device["deviceData"]["version"],
|
sw_version=self.device["deviceData"]["version"],
|
||||||
via_device=(DOMAIN, self.device["parentDevice"]),
|
via_device=(DOMAIN, self.device["parentDevice"]),
|
||||||
)
|
)
|
||||||
|
|
|
@ -39,9 +39,9 @@ class HiveDevicePlug(HiveEntity, SwitchEntity):
|
||||||
if self.device["hiveType"] == "activeplug":
|
if self.device["hiveType"] == "activeplug":
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self.device["device_id"])},
|
identifiers={(DOMAIN, self.device["device_id"])},
|
||||||
name=self.device["device_name"],
|
|
||||||
model=self.device["deviceData"]["model"],
|
|
||||||
manufacturer=self.device["deviceData"]["manufacturer"],
|
manufacturer=self.device["deviceData"]["manufacturer"],
|
||||||
|
model=self.device["deviceData"]["model"],
|
||||||
|
name=self.device["device_name"],
|
||||||
sw_version=self.device["deviceData"]["version"],
|
sw_version=self.device["deviceData"]["version"],
|
||||||
via_device=(DOMAIN, self.device["parentDevice"]),
|
via_device=(DOMAIN, self.device["parentDevice"]),
|
||||||
)
|
)
|
||||||
|
|
|
@ -83,9 +83,9 @@ class HiveWaterHeater(HiveEntity, WaterHeaterEntity):
|
||||||
"""Return device information."""
|
"""Return device information."""
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self.device["device_id"])},
|
identifiers={(DOMAIN, self.device["device_id"])},
|
||||||
name=self.device["device_name"],
|
|
||||||
model=self.device["deviceData"]["model"],
|
|
||||||
manufacturer=self.device["deviceData"]["manufacturer"],
|
manufacturer=self.device["deviceData"]["manufacturer"],
|
||||||
|
model=self.device["deviceData"]["model"],
|
||||||
|
name=self.device["device_name"],
|
||||||
sw_version=self.device["deviceData"]["version"],
|
sw_version=self.device["deviceData"]["version"],
|
||||||
via_device=(DOMAIN, self.device["parentDevice"]),
|
via_device=(DOMAIN, self.device["parentDevice"]),
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import logging
|
||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||||
|
|
||||||
from .api import HomeConnectDevice
|
from .api import HomeConnectDevice
|
||||||
from .const import DOMAIN, SIGNAL_UPDATE_ENTITIES
|
from .const import DOMAIN, SIGNAL_UPDATE_ENTITIES
|
||||||
|
@ -51,14 +51,14 @@ class HomeConnectEntity(Entity):
|
||||||
return f"{self.device.appliance.haId}-{self.desc}"
|
return f"{self.device.appliance.haId}-{self.desc}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return info about the device."""
|
"""Return info about the device."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self.device.appliance.haId)},
|
identifiers={(DOMAIN, self.device.appliance.haId)},
|
||||||
"name": self.device.appliance.name,
|
manufacturer=self.device.appliance.brand,
|
||||||
"manufacturer": self.device.appliance.brand,
|
model=self.device.appliance.vib,
|
||||||
"model": self.device.appliance.vib,
|
name=self.device.appliance.name,
|
||||||
}
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_entity_update(self):
|
def async_entity_update(self):
|
||||||
|
|
|
@ -8,6 +8,7 @@ from homeassistant.components.switch import (
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import dispatcher
|
from homeassistant.helpers import dispatcher
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from .const import DISPATCHER_REMOVERS, DOMAIN, HW_TYPE, SIGNAL_ADD_ENTITIES
|
from .const import DISPATCHER_REMOVERS, DOMAIN, HW_TYPE, SIGNAL_ADD_ENTITIES
|
||||||
|
@ -79,18 +80,18 @@ class HomeControlSwitchEntity(CoordinatorEntity, SwitchEntity):
|
||||||
return self.idx
|
return self.idx
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Device information."""
|
"""Device information."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {
|
identifiers={
|
||||||
# Unique identifiers within the domain
|
# Unique identifiers within the domain
|
||||||
(DOMAIN, self.unique_id)
|
(DOMAIN, self.unique_id)
|
||||||
},
|
},
|
||||||
"name": self.name,
|
manufacturer="Legrand",
|
||||||
"manufacturer": "Legrand",
|
model=HW_TYPE.get(self.module.hw_type),
|
||||||
"model": HW_TYPE.get(self.module.hw_type),
|
name=self.name,
|
||||||
"sw_version": self.module.fw,
|
sw_version=self.module.fw,
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
|
|
|
@ -152,9 +152,9 @@ class HomeKitEntity(Entity):
|
||||||
|
|
||||||
device_info = DeviceInfo(
|
device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, "serial-number", accessory_serial)},
|
identifiers={(DOMAIN, "serial-number", accessory_serial)},
|
||||||
name=info.value(CharacteristicsTypes.NAME),
|
|
||||||
manufacturer=info.value(CharacteristicsTypes.MANUFACTURER, ""),
|
manufacturer=info.value(CharacteristicsTypes.MANUFACTURER, ""),
|
||||||
model=info.value(CharacteristicsTypes.MODEL, ""),
|
model=info.value(CharacteristicsTypes.MODEL, ""),
|
||||||
|
name=info.value(CharacteristicsTypes.NAME),
|
||||||
sw_version=info.value(CharacteristicsTypes.FIRMWARE_REVISION, ""),
|
sw_version=info.value(CharacteristicsTypes.FIRMWARE_REVISION, ""),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,9 @@ class HomematicipAlarmControlPanelEntity(AlarmControlPanelEntity):
|
||||||
"""Return device specific attributes."""
|
"""Return device specific attributes."""
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(HMIPC_DOMAIN, f"ACP {self._home.id}")},
|
identifiers={(HMIPC_DOMAIN, f"ACP {self._home.id}")},
|
||||||
name=self.name,
|
|
||||||
manufacturer="eQ-3",
|
manufacturer="eQ-3",
|
||||||
model=CONST_ALARM_CONTROL_PANEL_NAME,
|
model=CONST_ALARM_CONTROL_PANEL_NAME,
|
||||||
|
name=self.name,
|
||||||
via_device=(HMIPC_DOMAIN, self._home.id),
|
via_device=(HMIPC_DOMAIN, self._home.id),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -172,12 +172,12 @@ class HomematicipCloudConnectionSensor(HomematicipGenericEntity, BinarySensorEnt
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return device specific attributes."""
|
"""Return device specific attributes."""
|
||||||
# Adds a sensor to the existing HAP device
|
# Adds a sensor to the existing HAP device
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {
|
identifiers={
|
||||||
# Serial numbers of Homematic IP device
|
# Serial numbers of Homematic IP device
|
||||||
(HMIPC_DOMAIN, self._home.id)
|
(HMIPC_DOMAIN, self._home.id)
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self) -> str:
|
def icon(self) -> str:
|
||||||
|
|
|
@ -78,9 +78,9 @@ class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity):
|
||||||
"""Return device specific attributes."""
|
"""Return device specific attributes."""
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(HMIPC_DOMAIN, self._device.id)},
|
identifiers={(HMIPC_DOMAIN, self._device.id)},
|
||||||
name=self._device.label,
|
|
||||||
manufacturer="eQ-3",
|
manufacturer="eQ-3",
|
||||||
model=self._device.modelType,
|
model=self._device.modelType,
|
||||||
|
name=self._device.label,
|
||||||
via_device=(HMIPC_DOMAIN, self._device.homeId),
|
via_device=(HMIPC_DOMAIN, self._device.homeId),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -101,9 +101,9 @@ class HomematicipGenericEntity(Entity):
|
||||||
# Serial numbers of Homematic IP device
|
# Serial numbers of Homematic IP device
|
||||||
(HMIPC_DOMAIN, self._device.id)
|
(HMIPC_DOMAIN, self._device.id)
|
||||||
},
|
},
|
||||||
name=self._device.label,
|
|
||||||
manufacturer=self._device.oem,
|
manufacturer=self._device.oem,
|
||||||
model=self._device.modelType,
|
model=self._device.modelType,
|
||||||
|
name=self._device.label,
|
||||||
sw_version=self._device.firmwareVersion,
|
sw_version=self._device.firmwareVersion,
|
||||||
# Link to the homematic ip access point.
|
# Link to the homematic ip access point.
|
||||||
via_device=(HMIPC_DOMAIN, self._device.homeId),
|
via_device=(HMIPC_DOMAIN, self._device.homeId),
|
||||||
|
|
|
@ -651,10 +651,10 @@ class HuaweiLteBaseEntity(Entity):
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Get info for matching with parent router."""
|
"""Get info for matching with parent router."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": self.router.device_identifiers,
|
connections=self.router.device_connections,
|
||||||
"connections": self.router.device_connections,
|
identifiers=self.router.device_identifiers,
|
||||||
}
|
)
|
||||||
|
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Update state."""
|
"""Update state."""
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""Support for the Philips Hue lights."""
|
"""Support for the Philips Hue lights."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import logging
|
import logging
|
||||||
|
@ -29,6 +31,7 @@ from homeassistant.components.light import (
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.exceptions import PlatformNotReady
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
from homeassistant.helpers.debounce import Debouncer
|
from homeassistant.helpers.debounce import Debouncer
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
DataUpdateCoordinator,
|
DataUpdateCoordinator,
|
||||||
|
@ -431,7 +434,7 @@ class HueLight(CoordinatorEntity, LightEntity):
|
||||||
return [EFFECT_COLORLOOP, EFFECT_RANDOM]
|
return [EFFECT_COLORLOOP, EFFECT_RANDOM]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo | None:
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
if self.light.type in (
|
if self.light.type in (
|
||||||
GROUP_TYPE_LIGHT_GROUP,
|
GROUP_TYPE_LIGHT_GROUP,
|
||||||
|
@ -441,22 +444,22 @@ class HueLight(CoordinatorEntity, LightEntity):
|
||||||
):
|
):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
info = {
|
suggested_area = None
|
||||||
"identifiers": {(HUE_DOMAIN, self.device_id)},
|
if self.light.id in self._rooms:
|
||||||
"name": self.name,
|
suggested_area = self._rooms[self.light.id]
|
||||||
"manufacturer": self.light.manufacturername,
|
|
||||||
|
return DeviceInfo(
|
||||||
|
identifiers={(HUE_DOMAIN, self.device_id)},
|
||||||
|
manufacturer=self.light.manufacturername,
|
||||||
# productname added in Hue Bridge API 1.24
|
# productname added in Hue Bridge API 1.24
|
||||||
# (published 03/05/2018)
|
# (published 03/05/2018)
|
||||||
"model": self.light.productname or self.light.modelid,
|
model=self.light.productname or self.light.modelid,
|
||||||
|
name=self.name,
|
||||||
# Not yet exposed as properties in aiohue
|
# Not yet exposed as properties in aiohue
|
||||||
"sw_version": self.light.raw["swversion"],
|
suggested_area=suggested_area,
|
||||||
"via_device": (HUE_DOMAIN, self.bridge.api.config.bridgeid),
|
sw_version=self.light.raw["swversion"],
|
||||||
}
|
via_device=(HUE_DOMAIN, self.bridge.api.config.bridgeid),
|
||||||
|
)
|
||||||
if self.light.id in self._rooms:
|
|
||||||
info["suggested_area"] = self._rooms[self.light.id]
|
|
||||||
|
|
||||||
return info
|
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Handle entity being added to Home Assistant."""
|
"""Handle entity being added to Home Assistant."""
|
||||||
|
|
|
@ -47,9 +47,9 @@ class GenericHueDevice(entity.Entity):
|
||||||
"""
|
"""
|
||||||
return entity.DeviceInfo(
|
return entity.DeviceInfo(
|
||||||
identifiers={(HUE_DOMAIN, self.device_id)},
|
identifiers={(HUE_DOMAIN, self.device_id)},
|
||||||
name=self.primary_sensor.name,
|
|
||||||
manufacturer=self.primary_sensor.manufacturername,
|
manufacturer=self.primary_sensor.manufacturername,
|
||||||
model=(self.primary_sensor.productname or self.primary_sensor.modelid),
|
model=(self.primary_sensor.productname or self.primary_sensor.modelid),
|
||||||
|
name=self.primary_sensor.name,
|
||||||
sw_version=self.primary_sensor.swversion,
|
sw_version=self.primary_sensor.swversion,
|
||||||
via_device=(HUE_DOMAIN, self.bridge.api.config.bridgeid),
|
via_device=(HUE_DOMAIN, self.bridge.api.config.bridgeid),
|
||||||
)
|
)
|
||||||
|
|
|
@ -43,15 +43,15 @@ class HDEntity(CoordinatorEntity):
|
||||||
firmware = self._device_info[DEVICE_FIRMWARE]
|
firmware = self._device_info[DEVICE_FIRMWARE]
|
||||||
sw_version = f"{firmware[FIRMWARE_REVISION]}.{firmware[FIRMWARE_SUB_REVISION]}.{firmware[FIRMWARE_BUILD]}"
|
sw_version = f"{firmware[FIRMWARE_REVISION]}.{firmware[FIRMWARE_SUB_REVISION]}.{firmware[FIRMWARE_BUILD]}"
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self._device_info[DEVICE_SERIAL_NUMBER])},
|
|
||||||
connections={
|
connections={
|
||||||
(dr.CONNECTION_NETWORK_MAC, self._device_info[DEVICE_MAC_ADDRESS])
|
(dr.CONNECTION_NETWORK_MAC, self._device_info[DEVICE_MAC_ADDRESS])
|
||||||
},
|
},
|
||||||
|
identifiers={(DOMAIN, self._device_info[DEVICE_SERIAL_NUMBER])},
|
||||||
|
manufacturer=MANUFACTURER,
|
||||||
|
model=self._device_info[DEVICE_MODEL],
|
||||||
name=self._device_info[DEVICE_NAME],
|
name=self._device_info[DEVICE_NAME],
|
||||||
suggested_area=self._room_name,
|
suggested_area=self._room_name,
|
||||||
model=self._device_info[DEVICE_MODEL],
|
|
||||||
sw_version=sw_version,
|
sw_version=sw_version,
|
||||||
manufacturer=MANUFACTURER,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ from homeassistant.components.binary_sensor import (
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION
|
from homeassistant.const import ATTR_ATTRIBUTION
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
DataUpdateCoordinator,
|
DataUpdateCoordinator,
|
||||||
|
@ -145,8 +146,8 @@ class HvvDepartureBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self):
|
||||||
"""Return the device info for this sensor."""
|
"""Return the device info for this sensor."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {
|
identifiers={
|
||||||
(
|
(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
self.config_entry.entry_id,
|
self.config_entry.entry_id,
|
||||||
|
@ -154,9 +155,9 @@ class HvvDepartureBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
||||||
self.config_entry.data[CONF_STATION]["type"],
|
self.config_entry.data[CONF_STATION]["type"],
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
"name": f"Departures at {self.config_entry.data[CONF_STATION]['name']}",
|
manufacturer=MANUFACTURER,
|
||||||
"manufacturer": MANUFACTURER,
|
name=f"Departures at {self.config_entry.data[CONF_STATION]['name']}",
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
@ -8,6 +8,7 @@ from pygti.exceptions import InvalidAuth
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, ATTR_ID, DEVICE_CLASS_TIMESTAMP
|
from homeassistant.const import ATTR_ATTRIBUTION, ATTR_ID, DEVICE_CLASS_TIMESTAMP
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
from homeassistant.util.dt import get_time_zone, utcnow
|
from homeassistant.util.dt import get_time_zone, utcnow
|
||||||
|
|
||||||
|
@ -158,8 +159,8 @@ class HVVDepartureSensor(SensorEntity):
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self):
|
||||||
"""Return the device info for this sensor."""
|
"""Return the device info for this sensor."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {
|
identifiers={
|
||||||
(
|
(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
self.config_entry.entry_id,
|
self.config_entry.entry_id,
|
||||||
|
@ -167,9 +168,9 @@ class HVVDepartureSensor(SensorEntity):
|
||||||
self.config_entry.data[CONF_STATION]["type"],
|
self.config_entry.data[CONF_STATION]["type"],
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
"name": self._name,
|
manufacturer=MANUFACTURER,
|
||||||
"manufacturer": MANUFACTURER,
|
name=self._name,
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
@ -249,12 +249,12 @@ class HyperionCamera(Camera):
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return device information."""
|
"""Return device information."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self._device_id)},
|
identifiers={(DOMAIN, self._device_id)},
|
||||||
"name": self._instance_name,
|
manufacturer=HYPERION_MANUFACTURER_NAME,
|
||||||
"manufacturer": HYPERION_MANUFACTURER_NAME,
|
model=HYPERION_MODEL_NAME,
|
||||||
"model": HYPERION_MODEL_NAME,
|
name=self._instance_name,
|
||||||
}
|
)
|
||||||
|
|
||||||
|
|
||||||
CAMERA_TYPES = {
|
CAMERA_TYPES = {
|
||||||
|
|
|
@ -240,12 +240,12 @@ class HyperionBaseLight(LightEntity):
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return device information."""
|
"""Return device information."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self._device_id)},
|
identifiers={(DOMAIN, self._device_id)},
|
||||||
"name": self._instance_name,
|
manufacturer=HYPERION_MANUFACTURER_NAME,
|
||||||
"manufacturer": HYPERION_MANUFACTURER_NAME,
|
model=HYPERION_MODEL_NAME,
|
||||||
"model": HYPERION_MODEL_NAME,
|
name=self._instance_name,
|
||||||
}
|
)
|
||||||
|
|
||||||
def _get_option(self, key: str) -> Any:
|
def _get_option(self, key: str) -> Any:
|
||||||
"""Get a value from the provided options."""
|
"""Get a value from the provided options."""
|
||||||
|
|
|
@ -185,12 +185,12 @@ class HyperionComponentSwitch(SwitchEntity):
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return device information."""
|
"""Return device information."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self._device_id)},
|
identifiers={(DOMAIN, self._device_id)},
|
||||||
"name": self._instance_name,
|
manufacturer=HYPERION_MANUFACTURER_NAME,
|
||||||
"manufacturer": HYPERION_MANUFACTURER_NAME,
|
model=HYPERION_MODEL_NAME,
|
||||||
"model": HYPERION_MODEL_NAME,
|
name=self._instance_name,
|
||||||
}
|
)
|
||||||
|
|
||||||
async def _async_send_set_component(self, value: bool) -> None:
|
async def _async_send_set_component(self, value: bool) -> None:
|
||||||
"""Send a component control request."""
|
"""Send a component control request."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue