Improve Glances entity descriptions, add long term statistics (#73049)

This commit is contained in:
avee87 2022-06-23 20:34:08 +01:00 committed by GitHub
parent d19fc0622b
commit 8865a58f74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,11 @@ from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass
import sys import sys
from homeassistant.components.sensor import SensorDeviceClass, SensorEntityDescription from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.const import DATA_GIBIBYTES, DATA_MEBIBYTES, PERCENTAGE, TEMP_CELSIUS from homeassistant.const import DATA_GIBIBYTES, DATA_MEBIBYTES, PERCENTAGE, TEMP_CELSIUS
DOMAIN = "glances" DOMAIN = "glances"
@ -40,6 +44,7 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="used percent", name_suffix="used percent",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon="mdi:harddisk", icon="mdi:harddisk",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="disk_use", key="disk_use",
@ -47,6 +52,7 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="used", name_suffix="used",
native_unit_of_measurement=DATA_GIBIBYTES, native_unit_of_measurement=DATA_GIBIBYTES,
icon="mdi:harddisk", icon="mdi:harddisk",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="disk_free", key="disk_free",
@ -54,6 +60,7 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="free", name_suffix="free",
native_unit_of_measurement=DATA_GIBIBYTES, native_unit_of_measurement=DATA_GIBIBYTES,
icon="mdi:harddisk", icon="mdi:harddisk",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="memory_use_percent", key="memory_use_percent",
@ -61,6 +68,7 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="RAM used percent", name_suffix="RAM used percent",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon="mdi:memory", icon="mdi:memory",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="memory_use", key="memory_use",
@ -68,6 +76,7 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="RAM used", name_suffix="RAM used",
native_unit_of_measurement=DATA_MEBIBYTES, native_unit_of_measurement=DATA_MEBIBYTES,
icon="mdi:memory", icon="mdi:memory",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="memory_free", key="memory_free",
@ -75,6 +84,7 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="RAM free", name_suffix="RAM free",
native_unit_of_measurement=DATA_MEBIBYTES, native_unit_of_measurement=DATA_MEBIBYTES,
icon="mdi:memory", icon="mdi:memory",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="swap_use_percent", key="swap_use_percent",
@ -82,6 +92,7 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="Swap used percent", name_suffix="Swap used percent",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon="mdi:memory", icon="mdi:memory",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="swap_use", key="swap_use",
@ -89,6 +100,7 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="Swap used", name_suffix="Swap used",
native_unit_of_measurement=DATA_GIBIBYTES, native_unit_of_measurement=DATA_GIBIBYTES,
icon="mdi:memory", icon="mdi:memory",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="swap_free", key="swap_free",
@ -96,41 +108,43 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="Swap free", name_suffix="Swap free",
native_unit_of_measurement=DATA_GIBIBYTES, native_unit_of_measurement=DATA_GIBIBYTES,
icon="mdi:memory", icon="mdi:memory",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="processor_load", key="processor_load",
type="load", type="load",
name_suffix="CPU load", name_suffix="CPU load",
native_unit_of_measurement="15 min",
icon=CPU_ICON, icon=CPU_ICON,
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="process_running", key="process_running",
type="processcount", type="processcount",
name_suffix="Running", name_suffix="Running",
native_unit_of_measurement="Count",
icon=CPU_ICON, icon=CPU_ICON,
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="process_total", key="process_total",
type="processcount", type="processcount",
name_suffix="Total", name_suffix="Total",
native_unit_of_measurement="Count",
icon=CPU_ICON, icon=CPU_ICON,
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="process_thread", key="process_thread",
type="processcount", type="processcount",
name_suffix="Thread", name_suffix="Thread",
native_unit_of_measurement="Count",
icon=CPU_ICON, icon=CPU_ICON,
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="process_sleeping", key="process_sleeping",
type="processcount", type="processcount",
name_suffix="Sleeping", name_suffix="Sleeping",
native_unit_of_measurement="Count", native_unit_of_measurement="",
icon=CPU_ICON, icon=CPU_ICON,
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="cpu_use_percent", key="cpu_use_percent",
@ -138,6 +152,7 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="CPU used", name_suffix="CPU used",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon=CPU_ICON, icon=CPU_ICON,
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="temperature_core", key="temperature_core",
@ -145,6 +160,7 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="Temperature", name_suffix="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="temperature_hdd", key="temperature_hdd",
@ -152,6 +168,7 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="Temperature", name_suffix="Temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="fan_speed", key="fan_speed",
@ -159,6 +176,7 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="Fan speed", name_suffix="Fan speed",
native_unit_of_measurement="RPM", native_unit_of_measurement="RPM",
icon="mdi:fan", icon="mdi:fan",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="battery", key="battery",
@ -166,13 +184,14 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="Charge", name_suffix="Charge",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon="mdi:battery", icon="mdi:battery",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="docker_active", key="docker_active",
type="docker", type="docker",
name_suffix="Containers active", name_suffix="Containers active",
native_unit_of_measurement="",
icon="mdi:docker", icon="mdi:docker",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="docker_cpu_use", key="docker_cpu_use",
@ -180,6 +199,7 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="Containers CPU used", name_suffix="Containers CPU used",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon="mdi:docker", icon="mdi:docker",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="docker_memory_use", key="docker_memory_use",
@ -187,17 +207,20 @@ SENSOR_TYPES: tuple[GlancesSensorEntityDescription, ...] = (
name_suffix="Containers RAM used", name_suffix="Containers RAM used",
native_unit_of_measurement=DATA_MEBIBYTES, native_unit_of_measurement=DATA_MEBIBYTES,
icon="mdi:docker", icon="mdi:docker",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="used", key="used",
type="raid", type="raid",
name_suffix="Raid used", name_suffix="Raid used",
icon="mdi:harddisk", icon="mdi:harddisk",
state_class=SensorStateClass.MEASUREMENT,
), ),
GlancesSensorEntityDescription( GlancesSensorEntityDescription(
key="available", key="available",
type="raid", type="raid",
name_suffix="Raid available", name_suffix="Raid available",
icon="mdi:harddisk", icon="mdi:harddisk",
state_class=SensorStateClass.MEASUREMENT,
), ),
) )