mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Add device_info to Glances entities (#73047)
This commit is contained in:
parent
a267045a31
commit
ad3bd6773c
@ -4,6 +4,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import CONF_NAME, STATE_UNAVAILABLE
|
from homeassistant.const import CONF_NAME, STATE_UNAVAILABLE
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DATA_UPDATED, DOMAIN, SENSOR_TYPES, GlancesSensorEntityDescription
|
from .const import DATA_UPDATED, DOMAIN, SENSOR_TYPES, GlancesSensorEntityDescription
|
||||||
@ -30,6 +31,7 @@ async def async_setup_entry(
|
|||||||
name,
|
name,
|
||||||
disk["mnt_point"],
|
disk["mnt_point"],
|
||||||
description,
|
description,
|
||||||
|
config_entry.entry_id,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif description.type == "sensors":
|
elif description.type == "sensors":
|
||||||
@ -42,11 +44,16 @@ async def async_setup_entry(
|
|||||||
name,
|
name,
|
||||||
sensor["label"],
|
sensor["label"],
|
||||||
description,
|
description,
|
||||||
|
config_entry.entry_id,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif description.type == "raid":
|
elif description.type == "raid":
|
||||||
for raid_device in client.api.data[description.type]:
|
for raid_device in client.api.data[description.type]:
|
||||||
dev.append(GlancesSensor(client, name, raid_device, description))
|
dev.append(
|
||||||
|
GlancesSensor(
|
||||||
|
client, name, raid_device, description, config_entry.entry_id
|
||||||
|
)
|
||||||
|
)
|
||||||
elif client.api.data[description.type]:
|
elif client.api.data[description.type]:
|
||||||
dev.append(
|
dev.append(
|
||||||
GlancesSensor(
|
GlancesSensor(
|
||||||
@ -54,6 +61,7 @@ async def async_setup_entry(
|
|||||||
name,
|
name,
|
||||||
"",
|
"",
|
||||||
description,
|
description,
|
||||||
|
config_entry.entry_id,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -71,6 +79,7 @@ class GlancesSensor(SensorEntity):
|
|||||||
name,
|
name,
|
||||||
sensor_name_prefix,
|
sensor_name_prefix,
|
||||||
description: GlancesSensorEntityDescription,
|
description: GlancesSensorEntityDescription,
|
||||||
|
config_entry_id: str,
|
||||||
):
|
):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self.glances_data = glances_data
|
self.glances_data = glances_data
|
||||||
@ -80,6 +89,11 @@ class GlancesSensor(SensorEntity):
|
|||||||
|
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._attr_name = f"{name} {sensor_name_prefix} {description.name_suffix}"
|
self._attr_name = f"{name} {sensor_name_prefix} {description.name_suffix}"
|
||||||
|
self._attr_device_info = DeviceInfo(
|
||||||
|
identifiers={(DOMAIN, config_entry_id)},
|
||||||
|
manufacturer="Glances",
|
||||||
|
name=name,
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user