mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 07:47:08 +00:00
Clean up Glances sensors a bit (#73998)
This commit is contained in:
parent
6ec6f0a835
commit
fb5e6aaa29
@ -7,6 +7,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
|||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
|
from . import GlancesData
|
||||||
from .const import DATA_UPDATED, DOMAIN, SENSOR_TYPES, GlancesSensorEntityDescription
|
from .const import DATA_UPDATED, DOMAIN, SENSOR_TYPES, GlancesSensorEntityDescription
|
||||||
|
|
||||||
|
|
||||||
@ -31,7 +32,6 @@ 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":
|
||||||
@ -44,16 +44,11 @@ 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(
|
dev.append(GlancesSensor(client, name, raid_device, description))
|
||||||
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(
|
||||||
@ -61,7 +56,6 @@ async def async_setup_entry(
|
|||||||
name,
|
name,
|
||||||
"",
|
"",
|
||||||
description,
|
description,
|
||||||
config_entry.entry_id,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -75,12 +69,11 @@ class GlancesSensor(SensorEntity):
|
|||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
glances_data,
|
glances_data: GlancesData,
|
||||||
name,
|
name: str,
|
||||||
sensor_name_prefix,
|
sensor_name_prefix: str,
|
||||||
description: GlancesSensorEntityDescription,
|
description: GlancesSensorEntityDescription,
|
||||||
config_entry_id: str,
|
) -> None:
|
||||||
):
|
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
self.glances_data = glances_data
|
self.glances_data = glances_data
|
||||||
self._sensor_name_prefix = sensor_name_prefix
|
self._sensor_name_prefix = sensor_name_prefix
|
||||||
@ -90,7 +83,7 @@ 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(
|
self._attr_device_info = DeviceInfo(
|
||||||
identifiers={(DOMAIN, config_entry_id)},
|
identifiers={(DOMAIN, glances_data.config_entry.entry_id)},
|
||||||
manufacturer="Glances",
|
manufacturer="Glances",
|
||||||
name=name,
|
name=name,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user