Use DeviceInfo Class L-M (#58312)
This commit is contained in:
parent
6341dd4883
commit
f2a5c4602e
27 changed files with 197 additions and 197 deletions
|
@ -34,11 +34,18 @@ from homeassistant.components.light import (
|
||||||
LightEntity,
|
LightEntity,
|
||||||
preprocess_turn_on_alternatives,
|
preprocess_turn_on_alternatives,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_MODE, EVENT_HOMEASSISTANT_STOP
|
from homeassistant.const import (
|
||||||
|
ATTR_ENTITY_ID,
|
||||||
|
ATTR_MODE,
|
||||||
|
ATTR_MODEL,
|
||||||
|
ATTR_SW_VERSION,
|
||||||
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers import entity_platform
|
from homeassistant.helpers import entity_platform
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
import homeassistant.helpers.device_registry as dr
|
import homeassistant.helpers.device_registry as dr
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.event import async_track_point_in_utc_time
|
from homeassistant.helpers.event import async_track_point_in_utc_time
|
||||||
import homeassistant.util.color as color_util
|
import homeassistant.util.color as color_util
|
||||||
|
|
||||||
|
@ -449,24 +456,19 @@ class LIFXLight(LightEntity):
|
||||||
self.lock = asyncio.Lock()
|
self.lock = asyncio.Lock()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return information about the device."""
|
"""Return information about the device."""
|
||||||
info = {
|
_map = aiolifx().products.product_map
|
||||||
"identifiers": {(LIFX_DOMAIN, self.unique_id)},
|
info = DeviceInfo(
|
||||||
"name": self.name,
|
identifiers={(LIFX_DOMAIN, self.unique_id)},
|
||||||
"connections": {(dr.CONNECTION_NETWORK_MAC, self.bulb.mac_addr)},
|
connections={(dr.CONNECTION_NETWORK_MAC, self.bulb.mac_addr)},
|
||||||
"manufacturer": "LIFX",
|
manufacturer="LIFX",
|
||||||
}
|
name=self.name,
|
||||||
|
)
|
||||||
|
if model := (_map.get(self.bulb.product) or self.bulb.product) is not None:
|
||||||
|
info[ATTR_MODEL] = str(model)
|
||||||
if (version := self.bulb.host_firmware_version) is not None:
|
if (version := self.bulb.host_firmware_version) is not None:
|
||||||
info["sw_version"] = version
|
info[ATTR_SW_VERSION] = version
|
||||||
|
|
||||||
product_map = aiolifx().products.product_map
|
|
||||||
|
|
||||||
model = product_map.get(self.bulb.product) or self.bulb.product
|
|
||||||
if model is not None:
|
|
||||||
info["model"] = str(model)
|
|
||||||
|
|
||||||
return info
|
return info
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -46,12 +46,12 @@ class LitterRobotEntity(CoordinatorEntity):
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device information for a Litter-Robot."""
|
"""Return the device information for a Litter-Robot."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self.robot.serial)},
|
identifiers={(DOMAIN, self.robot.serial)},
|
||||||
"name": self.robot.name,
|
manufacturer="Litter-Robot",
|
||||||
"manufacturer": "Litter-Robot",
|
model=self.robot.model,
|
||||||
"model": self.robot.model,
|
name=self.robot.name,
|
||||||
}
|
)
|
||||||
|
|
||||||
|
|
||||||
class LitterRobotControlEntity(LitterRobotEntity):
|
class LitterRobotControlEntity(LitterRobotEntity):
|
||||||
|
|
|
@ -14,6 +14,7 @@ from homeassistant.const import (
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTRIBUTION,
|
ATTRIBUTION,
|
||||||
|
@ -116,15 +117,15 @@ class LogiCam(Camera):
|
||||||
return SUPPORT_ON_OFF
|
return SUPPORT_ON_OFF
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return information about the device."""
|
"""Return information about the device."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"name": self._camera.name,
|
identifiers={(LOGI_CIRCLE_DOMAIN, self._camera.id)},
|
||||||
"identifiers": {(LOGI_CIRCLE_DOMAIN, self._camera.id)},
|
manufacturer=DEVICE_BRAND,
|
||||||
"model": self._camera.model_name,
|
model=self._camera.model_name,
|
||||||
"sw_version": self._camera.firmware,
|
name=self._camera.name,
|
||||||
"manufacturer": DEVICE_BRAND,
|
sw_version=self._camera.firmware,
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
|
|
|
@ -13,6 +13,7 @@ from homeassistant.const import (
|
||||||
STATE_OFF,
|
STATE_OFF,
|
||||||
STATE_ON,
|
STATE_ON,
|
||||||
)
|
)
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.icon import icon_for_battery_level
|
from homeassistant.helpers.icon import icon_for_battery_level
|
||||||
from homeassistant.util.dt import as_local
|
from homeassistant.util.dt import as_local
|
||||||
|
|
||||||
|
@ -56,15 +57,15 @@ class LogiSensor(SensorEntity):
|
||||||
self._tz = time_zone
|
self._tz = time_zone
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return information about the device."""
|
"""Return information about the device."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"name": self._camera.name,
|
identifiers={(LOGI_CIRCLE_DOMAIN, self._camera.id)},
|
||||||
"identifiers": {(LOGI_CIRCLE_DOMAIN, self._camera.id)},
|
manufacturer=DEVICE_BRAND,
|
||||||
"model": self._camera.model_name,
|
model=self._camera.model_name,
|
||||||
"sw_version": self._camera.firmware,
|
name=self._camera.name,
|
||||||
"manufacturer": DEVICE_BRAND,
|
sw_version=self._camera.firmware,
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
|
|
|
@ -333,10 +333,10 @@ class LutronCasetaDevice(Entity):
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return DeviceInfo(
|
return DeviceInfo(
|
||||||
identifiers={(DOMAIN, self.serial)},
|
identifiers={(DOMAIN, self.serial)},
|
||||||
name=self.name,
|
|
||||||
suggested_area=self._device["name"].split("_")[0],
|
|
||||||
manufacturer=MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
model=f"{self._device['model']} ({self._device['type']})",
|
model=f"{self._device['model']} ({self._device['type']})",
|
||||||
|
name=self.name,
|
||||||
|
suggested_area=self._device["name"].split("_")[0],
|
||||||
via_device=(DOMAIN, self._bridge_device["serial"]),
|
via_device=(DOMAIN, self._bridge_device["serial"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -170,9 +170,9 @@ class LyricDeviceEntity(LyricEntity):
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return device information about this Honeywell Lyric instance."""
|
"""Return device information about this Honeywell Lyric instance."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"connections": {(dr.CONNECTION_NETWORK_MAC, self._mac_id)},
|
connections={(dr.CONNECTION_NETWORK_MAC, self._mac_id)},
|
||||||
"manufacturer": "Honeywell",
|
manufacturer="Honeywell",
|
||||||
"model": self.device.deviceModel,
|
model=self.device.deviceModel,
|
||||||
"name": self.device.name,
|
name=self.device.name,
|
||||||
}
|
)
|
||||||
|
|
|
@ -23,6 +23,7 @@ from homeassistant.exceptions import (
|
||||||
)
|
)
|
||||||
from homeassistant.helpers import aiohttp_client, device_registry
|
from homeassistant.helpers import aiohttp_client, device_registry
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
DataUpdateCoordinator,
|
DataUpdateCoordinator,
|
||||||
|
@ -229,14 +230,14 @@ class MazdaEntity(CoordinatorEntity):
|
||||||
return self.coordinator.data[self.index]
|
return self.coordinator.data[self.index]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return device info for the Mazda entity."""
|
"""Return device info for the Mazda entity."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self.vin)},
|
identifiers={(DOMAIN, self.vin)},
|
||||||
"name": self.get_vehicle_name(),
|
manufacturer="Mazda",
|
||||||
"manufacturer": "Mazda",
|
model=f"{self.data['modelYear']} {self.data['carlineName']}",
|
||||||
"model": f"{self.data['modelYear']} {self.data['carlineName']}",
|
name=self.get_vehicle_name(),
|
||||||
}
|
)
|
||||||
|
|
||||||
def get_vehicle_name(self):
|
def get_vehicle_name(self):
|
||||||
"""Return the vehicle name, to be used as a prefix for names of other entities."""
|
"""Return the vehicle name, to be used as a prefix for names of other entities."""
|
||||||
|
|
|
@ -17,6 +17,7 @@ from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
|
|
||||||
|
@ -126,19 +127,19 @@ class MelCloudDevice:
|
||||||
return self.device.building_id
|
return self.device.building_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return a device description for device registry."""
|
"""Return a device description for device registry."""
|
||||||
_device_info = {
|
model = None
|
||||||
"connections": {(CONNECTION_NETWORK_MAC, self.device.mac)},
|
unit_infos = self.device.units
|
||||||
"identifiers": {(DOMAIN, f"{self.device.mac}-{self.device.serial}")},
|
if unit_infos is not None:
|
||||||
"manufacturer": "Mitsubishi Electric",
|
model = ", ".join([x["model"] for x in unit_infos if x["model"]])
|
||||||
"name": self.name,
|
return DeviceInfo(
|
||||||
}
|
connections={(CONNECTION_NETWORK_MAC, self.device.mac)},
|
||||||
if (unit_infos := self.device.units) is not None:
|
identifiers={(DOMAIN, f"{self.device.mac}-{self.device.serial}")},
|
||||||
_device_info["model"] = ", ".join(
|
manufacturer="Mitsubishi Electric",
|
||||||
[x["model"] for x in unit_infos if x["model"]]
|
model=model,
|
||||||
)
|
name=self.name,
|
||||||
return _device_info
|
)
|
||||||
|
|
||||||
|
|
||||||
async def mel_devices_setup(hass, token) -> list[MelCloudDevice]:
|
async def mel_devices_setup(hass, token) -> list[MelCloudDevice]:
|
||||||
|
|
|
@ -30,6 +30,7 @@ from homeassistant.const import (
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
from homeassistant.util.distance import convert as convert_distance
|
from homeassistant.util.distance import convert as convert_distance
|
||||||
from homeassistant.util.pressure import convert as convert_pressure
|
from homeassistant.util.pressure import convert as convert_pressure
|
||||||
|
@ -247,10 +248,10 @@ class MetWeather(CoordinatorEntity, WeatherEntity):
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self):
|
||||||
"""Device info."""
|
"""Device info."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN,)},
|
default_name="Forecast",
|
||||||
"manufacturer": "Met.no",
|
entry_type="service",
|
||||||
"model": "Forecast",
|
identifiers={(DOMAIN,)},
|
||||||
"default_name": "Forecast",
|
manufacturer="Met.no",
|
||||||
"entry_type": "service",
|
model="Forecast",
|
||||||
}
|
)
|
||||||
|
|
|
@ -20,6 +20,7 @@ from homeassistant.const import (
|
||||||
PRESSURE_INHG,
|
PRESSURE_INHG,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
from homeassistant.util.distance import convert as convert_distance
|
from homeassistant.util.distance import convert as convert_distance
|
||||||
|
@ -182,10 +183,10 @@ class MetEireannWeather(CoordinatorEntity, WeatherEntity):
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self):
|
||||||
"""Device info."""
|
"""Device info."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN,)},
|
default_name="Forecast",
|
||||||
"manufacturer": "Met Éireann",
|
entry_type="service",
|
||||||
"model": "Forecast",
|
identifiers={(DOMAIN,)},
|
||||||
"default_name": "Forecast",
|
manufacturer="Met Éireann",
|
||||||
"entry_type": "service",
|
model="Forecast",
|
||||||
}
|
)
|
||||||
|
|
|
@ -8,6 +8,7 @@ from homeassistant.components.sensor import SensorEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION
|
from homeassistant.const import ATTR_ATTRIBUTION
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
DataUpdateCoordinator,
|
DataUpdateCoordinator,
|
||||||
|
@ -92,15 +93,15 @@ class MeteoFranceSensor(CoordinatorEntity, SensorEntity):
|
||||||
self._attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
self._attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self.platform.config_entry.unique_id)},
|
entry_type="service",
|
||||||
"name": self.coordinator.name,
|
identifiers={(DOMAIN, self.platform.config_entry.unique_id)},
|
||||||
"manufacturer": MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
"model": MODEL,
|
model=MODEL,
|
||||||
"entry_type": "service",
|
name=self.coordinator.name,
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
|
|
|
@ -15,6 +15,7 @@ from homeassistant.components.weather import (
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_MODE, TEMP_CELSIUS
|
from homeassistant.const import CONF_MODE, TEMP_CELSIUS
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
DataUpdateCoordinator,
|
DataUpdateCoordinator,
|
||||||
|
@ -86,15 +87,15 @@ class MeteoFranceWeather(CoordinatorEntity, WeatherEntity):
|
||||||
return self._city_name
|
return self._city_name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self.platform.config_entry.unique_id)},
|
entry_type="service",
|
||||||
"name": self.coordinator.name,
|
identifiers={(DOMAIN, self.platform.config_entry.unique_id)},
|
||||||
"manufacturer": MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
"model": MODEL,
|
model=MODEL,
|
||||||
"entry_type": "service",
|
name=self.coordinator.name,
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def condition(self):
|
def condition(self):
|
||||||
|
|
|
@ -3,6 +3,7 @@ from homeassistant.components.sensor import SensorEntity, SensorEntityDescriptio
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION
|
from homeassistant.const import ATTR_ATTRIBUTION
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
DataUpdateCoordinator,
|
DataUpdateCoordinator,
|
||||||
|
@ -41,13 +42,13 @@ class MeteoclimaticSensor(CoordinatorEntity, SensorEntity):
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self):
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self.platform.config_entry.unique_id)},
|
entry_type="service",
|
||||||
"name": self.coordinator.name,
|
identifiers={(DOMAIN, self.platform.config_entry.unique_id)},
|
||||||
"manufacturer": MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
"model": MODEL,
|
model=MODEL,
|
||||||
"entry_type": "service",
|
name=self.coordinator.name,
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
|
|
|
@ -5,6 +5,7 @@ from homeassistant.components.weather import WeatherEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import TEMP_CELSIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
CoordinatorEntity,
|
CoordinatorEntity,
|
||||||
|
@ -55,13 +56,13 @@ class MeteoclimaticWeather(CoordinatorEntity, WeatherEntity):
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self):
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self.platform.config_entry.unique_id)},
|
entry_type="service",
|
||||||
"name": self.coordinator.name,
|
identifiers={(DOMAIN, self.platform.config_entry.unique_id)},
|
||||||
"manufacturer": MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
"model": MODEL,
|
model=MODEL,
|
||||||
"entry_type": "service",
|
name=self.coordinator.name,
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def condition(self):
|
def condition(self):
|
||||||
|
|
|
@ -10,6 +10,7 @@ from homeassistant.core import callback
|
||||||
from homeassistant.helpers import entity_registry
|
from homeassistant.helpers import entity_registry
|
||||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -130,16 +131,15 @@ class MikrotikHubTracker(ScannerEntity):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return a client description for device registry."""
|
"""Return a client description for device registry."""
|
||||||
info = {
|
# We only get generic info from device discovery and so don't want
|
||||||
"connections": {(CONNECTION_NETWORK_MAC, self.device.mac)},
|
# to override API specific info that integrations can provide
|
||||||
"identifiers": {(DOMAIN, self.device.mac)},
|
return DeviceInfo(
|
||||||
# We only get generic info from device discovery and so don't want
|
connections={(CONNECTION_NETWORK_MAC, self.device.mac)},
|
||||||
# to override API specific info that integrations can provide
|
default_name=self.name,
|
||||||
"default_name": self.name,
|
identifiers={(DOMAIN, self.device.mac)},
|
||||||
}
|
)
|
||||||
return info
|
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Client entity created."""
|
"""Client entity created."""
|
||||||
|
|
|
@ -86,9 +86,9 @@ class MillHeater(CoordinatorEntity, ClimateEntity):
|
||||||
self._attr_name = heater.name
|
self._attr_name = heater.name
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, heater.device_id)},
|
identifiers={(DOMAIN, heater.device_id)},
|
||||||
name=self.name,
|
|
||||||
manufacturer=MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
model=f"generation {1 if heater.is_gen1 else 2}",
|
model=f"generation {1 if heater.is_gen1 else 2}",
|
||||||
|
name=self.name,
|
||||||
)
|
)
|
||||||
if heater.is_gen1:
|
if heater.is_gen1:
|
||||||
self._attr_hvac_modes = [HVAC_MODE_HEAT]
|
self._attr_hvac_modes = [HVAC_MODE_HEAT]
|
||||||
|
|
|
@ -44,9 +44,9 @@ class MillHeaterEnergySensor(CoordinatorEntity, SensorEntity):
|
||||||
self._attr_unique_id = f"{heater.device_id}_{sensor_type}"
|
self._attr_unique_id = f"{heater.device_id}_{sensor_type}"
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, heater.device_id)},
|
identifiers={(DOMAIN, heater.device_id)},
|
||||||
name=self.name,
|
|
||||||
manufacturer=MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
model=f"generation {1 if heater.is_gen1 else 2}",
|
model=f"generation {1 if heater.is_gen1 else 2}",
|
||||||
|
name=self.name,
|
||||||
)
|
)
|
||||||
self._update_attr(heater)
|
self._update_attr(heater)
|
||||||
|
|
||||||
|
|
|
@ -224,13 +224,13 @@ class MinecraftServerEntity(Entity):
|
||||||
self._name = f"{server.name} {type_name}"
|
self._name = f"{server.name} {type_name}"
|
||||||
self._icon = icon
|
self._icon = icon
|
||||||
self._unique_id = f"{self._server.unique_id}-{type_name}"
|
self._unique_id = f"{self._server.unique_id}-{type_name}"
|
||||||
self._device_info = {
|
self._attr_device_info = DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self._server.unique_id)},
|
identifiers={(DOMAIN, self._server.unique_id)},
|
||||||
"name": self._server.name,
|
manufacturer=MANUFACTURER,
|
||||||
"manufacturer": MANUFACTURER,
|
model=f"Minecraft Server ({self._server.version})",
|
||||||
"model": f"Minecraft Server ({self._server.version})",
|
name=self._server.name,
|
||||||
"sw_version": self._server.protocol_version,
|
sw_version=self._server.protocol_version,
|
||||||
}
|
)
|
||||||
self._device_class = device_class
|
self._device_class = device_class
|
||||||
self._extra_state_attributes = None
|
self._extra_state_attributes = None
|
||||||
self._disconnect_dispatcher = None
|
self._disconnect_dispatcher = None
|
||||||
|
@ -245,11 +245,6 @@ class MinecraftServerEntity(Entity):
|
||||||
"""Return unique ID."""
|
"""Return unique ID."""
|
||||||
return self._unique_id
|
return self._unique_id
|
||||||
|
|
||||||
@property
|
|
||||||
def device_info(self) -> DeviceInfo:
|
|
||||||
"""Return device information."""
|
|
||||||
return self._device_info
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> str:
|
||||||
"""Return device class."""
|
"""Return device class."""
|
||||||
|
|
|
@ -174,10 +174,10 @@ def webhook_response(
|
||||||
|
|
||||||
def device_info(registration: dict) -> DeviceInfo:
|
def device_info(registration: dict) -> DeviceInfo:
|
||||||
"""Return the device info for this registration."""
|
"""Return the device info for this registration."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, registration[ATTR_DEVICE_ID])},
|
identifiers={(DOMAIN, registration[ATTR_DEVICE_ID])},
|
||||||
"manufacturer": registration[ATTR_MANUFACTURER],
|
manufacturer=registration[ATTR_MANUFACTURER],
|
||||||
"model": registration[ATTR_MODEL],
|
model=registration[ATTR_MODEL],
|
||||||
"name": registration[ATTR_DEVICE_NAME],
|
name=registration[ATTR_DEVICE_NAME],
|
||||||
"sw_version": registration[ATTR_OS_VERSION],
|
sw_version=registration[ATTR_OS_VERSION],
|
||||||
}
|
)
|
||||||
|
|
|
@ -17,14 +17,7 @@ from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
|
||||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import CONF_HOST
|
||||||
ATTR_IDENTIFIERS,
|
|
||||||
ATTR_MANUFACTURER,
|
|
||||||
ATTR_MODEL,
|
|
||||||
ATTR_NAME,
|
|
||||||
ATTR_SW_VERSION,
|
|
||||||
CONF_HOST,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
@ -159,10 +152,10 @@ class ModernFormsDeviceEntity(CoordinatorEntity[ModernFormsDataUpdateCoordinator
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return device information about this Modern Forms device."""
|
"""Return device information about this Modern Forms device."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
ATTR_IDENTIFIERS: {(DOMAIN, self.coordinator.data.info.mac_address)},
|
identifiers={(DOMAIN, self.coordinator.data.info.mac_address)},
|
||||||
ATTR_NAME: self.coordinator.data.info.device_name,
|
name=self.coordinator.data.info.device_name,
|
||||||
ATTR_MANUFACTURER: "Modern Forms",
|
manufacturer="Modern Forms",
|
||||||
ATTR_MODEL: self.coordinator.data.info.fan_type,
|
model=self.coordinator.data.info.fan_type,
|
||||||
ATTR_SW_VERSION: f"{self.coordinator.data.info.firmware_version} / {self.coordinator.data.info.main_mcu_firmware_version}",
|
sw_version=f"{self.coordinator.data.info.firmware_version} / {self.coordinator.data.info.main_mcu_firmware_version}",
|
||||||
}
|
)
|
||||||
|
|
|
@ -15,6 +15,7 @@ from homeassistant.components.media_player.const import (
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_PORT, STATE_OFF, STATE_ON
|
from homeassistant.const import CONF_PORT, STATE_OFF, STATE_ON
|
||||||
from homeassistant.helpers import config_validation as cv, entity_platform, service
|
from homeassistant.helpers import config_validation as cv, entity_platform, service
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_SOURCES,
|
CONF_SOURCES,
|
||||||
|
@ -167,14 +168,14 @@ class MonopriceZone(MediaPlayerEntity):
|
||||||
return self._zone_id < 20 or self._update_success
|
return self._zone_id < 20 or self._update_success
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return device info for this device."""
|
"""Return device info for this device."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self.unique_id)},
|
identifiers={(DOMAIN, self.unique_id)},
|
||||||
"name": self.name,
|
manufacturer="Monoprice",
|
||||||
"manufacturer": "Monoprice",
|
model="6-Zone Amplifier",
|
||||||
"model": "6-Zone Amplifier",
|
name=self.name,
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
|
|
|
@ -142,8 +142,8 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity):
|
||||||
self._attr_device_info = DeviceInfo(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, blind.mac)},
|
identifiers={(DOMAIN, blind.mac)},
|
||||||
manufacturer=MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
name=f"{blind.blind_type}-{blind.mac[12:]}",
|
|
||||||
model=blind.blind_type,
|
model=blind.blind_type,
|
||||||
|
name=f"{blind.blind_type}-{blind.mac[12:]}",
|
||||||
via_device=(DOMAIN, config_entry.unique_id),
|
via_device=(DOMAIN, config_entry.unique_id),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ from homeassistant.const import (
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
)
|
)
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from .const import ATTR_AVAILABLE, DOMAIN, KEY_COORDINATOR, KEY_GATEWAY
|
from .const import ATTR_AVAILABLE, DOMAIN, KEY_COORDINATOR, KEY_GATEWAY
|
||||||
|
@ -50,7 +51,7 @@ class MotionBatterySensor(CoordinatorEntity, SensorEntity):
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
|
|
||||||
self._blind = blind
|
self._blind = blind
|
||||||
self._attr_device_info = {"identifiers": {(DOMAIN, blind.mac)}}
|
self._attr_device_info = DeviceInfo(identifiers={(DOMAIN, blind.mac)})
|
||||||
self._attr_name = f"{blind.blind_type}-battery-{blind.mac[12:]}"
|
self._attr_name = f"{blind.blind_type}-battery-{blind.mac[12:]}"
|
||||||
self._attr_unique_id = f"{blind.mac}-battery"
|
self._attr_unique_id = f"{blind.mac}-battery"
|
||||||
|
|
||||||
|
@ -128,7 +129,7 @@ class MotionSignalStrengthSensor(CoordinatorEntity, SensorEntity):
|
||||||
|
|
||||||
self._device = device
|
self._device = device
|
||||||
self._device_type = device_type
|
self._device_type = device_type
|
||||||
self._attr_device_info = {"identifiers": {(DOMAIN, device.mac)}}
|
self._attr_device_info = DeviceInfo(identifiers={(DOMAIN, device.mac)})
|
||||||
self._attr_unique_id = f"{device.mac}-RSSI"
|
self._attr_unique_id = f"{device.mac}-RSSI"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -477,4 +477,4 @@ class MotionEyeEntity(CoordinatorEntity):
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device information."""
|
"""Return the device information."""
|
||||||
return {"identifiers": {self._device_identifier}}
|
return DeviceInfo(identifiers={self._device_identifier})
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
"""mütesync binary sensor entities."""
|
"""mütesync binary sensor entities."""
|
||||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||||
from homeassistant.helpers import update_coordinator
|
from homeassistant.helpers import update_coordinator
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
@ -42,12 +43,12 @@ class MuteStatus(update_coordinator.CoordinatorEntity, BinarySensorEntity):
|
||||||
return self.coordinator.data[self._sensor_type]
|
return self.coordinator.data[self._sensor_type]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info of the sensor."""
|
"""Return the device info of the sensor."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, self.coordinator.data["user-id"])},
|
entry_type="service",
|
||||||
"name": "mutesync",
|
identifiers={(DOMAIN, self.coordinator.data["user-id"])},
|
||||||
"manufacturer": "mütesync",
|
manufacturer="mütesync",
|
||||||
"model": "mutesync app",
|
model="mutesync app",
|
||||||
"entry_type": "service",
|
name="mutesync",
|
||||||
}
|
)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
"""The MyQ integration."""
|
"""The MyQ integration."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -13,12 +15,7 @@ from pymyq.device import MyQDevice
|
||||||
from pymyq.errors import InvalidCredentialsError, MyQError
|
from pymyq.errors import InvalidCredentialsError, MyQError
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||||
ATTR_MODEL,
|
|
||||||
ATTR_VIA_DEVICE,
|
|
||||||
CONF_PASSWORD,
|
|
||||||
CONF_USERNAME,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
|
@ -97,24 +94,24 @@ class MyQEntity(CoordinatorEntity):
|
||||||
return self._device.name
|
return self._device.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self):
|
||||||
"""Return the device_info of the device."""
|
"""Return the device_info of the device."""
|
||||||
device_info = DeviceInfo(
|
|
||||||
identifiers={(DOMAIN, self._device.device_id)},
|
|
||||||
name=self._device.name,
|
|
||||||
manufacturer=MANUFACTURER,
|
|
||||||
sw_version=self._device.firmware_version,
|
|
||||||
)
|
|
||||||
model = (
|
model = (
|
||||||
KNOWN_MODELS.get(self._device.device_id[2:4])
|
KNOWN_MODELS.get(self._device.device_id[2:4])
|
||||||
if self._device.device_id is not None
|
if self._device.device_id is not None
|
||||||
else None
|
else None
|
||||||
)
|
)
|
||||||
if model:
|
via_device: tuple[str, str] | None = None
|
||||||
device_info[ATTR_MODEL] = model
|
|
||||||
if self._device.parent_device_id:
|
if self._device.parent_device_id:
|
||||||
device_info[ATTR_VIA_DEVICE] = (DOMAIN, self._device.parent_device_id)
|
via_device = (DOMAIN, self._device.parent_device_id)
|
||||||
return device_info
|
return DeviceInfo(
|
||||||
|
identifiers={(DOMAIN, self._device.device_id)},
|
||||||
|
manufacturer=MANUFACTURER,
|
||||||
|
model=model,
|
||||||
|
name=self._device.name,
|
||||||
|
sw_version=self._device.firmware_version,
|
||||||
|
via_device=via_device,
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self):
|
||||||
|
|
|
@ -121,12 +121,12 @@ class MySensorsDevice:
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> DeviceInfo:
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return the device info."""
|
"""Return the device info."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, f"{self.gateway_id}-{self.node_id}")},
|
identifiers={(DOMAIN, f"{self.gateway_id}-{self.node_id}")},
|
||||||
"name": self.node_name,
|
manufacturer=DOMAIN,
|
||||||
"manufacturer": DOMAIN,
|
name=self.node_name,
|
||||||
"sw_version": self.sketch_version,
|
sw_version=self.sketch_version,
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue