From ad3bd6773c5da0ab9827ee0f73d6c1d141fc4c78 Mon Sep 17 00:00:00 2001 From: avee87 <6134677+avee87@users.noreply.github.com> Date: Sat, 25 Jun 2022 00:23:26 +0100 Subject: [PATCH] Add device_info to Glances entities (#73047) --- homeassistant/components/glances/sensor.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/glances/sensor.py b/homeassistant/components/glances/sensor.py index a907dd1695a..0d60747ecaa 100644 --- a/homeassistant/components/glances/sensor.py +++ b/homeassistant/components/glances/sensor.py @@ -4,6 +4,7 @@ from homeassistant.config_entries import ConfigEntry 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 @@ -30,6 +31,7 @@ async def async_setup_entry( name, disk["mnt_point"], description, + config_entry.entry_id, ) ) elif description.type == "sensors": @@ -42,11 +44,16 @@ 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( @@ -54,6 +61,7 @@ async def async_setup_entry( name, "", description, + config_entry.entry_id, ) ) @@ -71,6 +79,7 @@ class GlancesSensor(SensorEntity): name, sensor_name_prefix, description: GlancesSensorEntityDescription, + config_entry_id: str, ): """Initialize the sensor.""" self.glances_data = glances_data @@ -80,6 +89,11 @@ class GlancesSensor(SensorEntity): 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):