Skip to content

Commit

Permalink
Add device_info to Glances entities (home-assistant#73047)
Browse files Browse the repository at this point in the history
  • Loading branch information
avee87 authored Jun 24, 2022
1 parent a267045 commit ad3bd67
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion homeassistant/components/glances/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from homeassistant.const import CONF_NAME, STATE_UNAVAILABLE
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DATA_UPDATED, DOMAIN, SENSOR_TYPES, GlancesSensorEntityDescription
Expand All @@ -30,6 +31,7 @@ async def async_setup_entry(
name,
disk["mnt_point"],
description,
config_entry.entry_id,
)
)
elif description.type == "sensors":
Expand All @@ -42,18 +44,24 @@ async def async_setup_entry(
name,
sensor["label"],
description,
config_entry.entry_id,
)
)
elif description.type == "raid":
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]:
dev.append(
GlancesSensor(
client,
name,
"",
description,
config_entry.entry_id,
)
)

Expand All @@ -71,6 +79,7 @@ def __init__(
name,
sensor_name_prefix,
description: GlancesSensorEntityDescription,
config_entry_id: str,
):
"""Initialize the sensor."""
self.glances_data = glances_data
Expand All @@ -80,6 +89,11 @@ def __init__(

self.entity_description = description
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
def unique_id(self):
Expand Down

0 comments on commit ad3bd67

Please sign in to comment.