Correct state classes for systemmonitor sensors (#57615)

This commit is contained in:
Michael 2021-10-14 08:45:58 +02:00 committed by GitHub
parent 827501659c
commit 0da1f9544e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,7 +16,7 @@ import voluptuous as vol
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
STATE_CLASS_TOTAL, STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING, STATE_CLASS_TOTAL_INCREASING,
SensorEntity, SensorEntity,
SensorEntityDescription, SensorEntityDescription,
@ -80,21 +80,21 @@ SENSOR_TYPES: dict[str, SysMonitorSensorEntityDescription] = {
name="Disk free", name="Disk free",
native_unit_of_measurement=DATA_GIBIBYTES, native_unit_of_measurement=DATA_GIBIBYTES,
icon="mdi:harddisk", icon="mdi:harddisk",
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
"disk_use": SysMonitorSensorEntityDescription( "disk_use": SysMonitorSensorEntityDescription(
key="disk_use", key="disk_use",
name="Disk use", name="Disk use",
native_unit_of_measurement=DATA_GIBIBYTES, native_unit_of_measurement=DATA_GIBIBYTES,
icon="mdi:harddisk", icon="mdi:harddisk",
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
"disk_use_percent": SysMonitorSensorEntityDescription( "disk_use_percent": SysMonitorSensorEntityDescription(
key="disk_use_percent", key="disk_use_percent",
name="Disk use (percent)", name="Disk use (percent)",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon="mdi:harddisk", icon="mdi:harddisk",
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
"ipv4_address": SysMonitorSensorEntityDescription( "ipv4_address": SysMonitorSensorEntityDescription(
key="ipv4_address", key="ipv4_address",
@ -117,40 +117,40 @@ SENSOR_TYPES: dict[str, SysMonitorSensorEntityDescription] = {
key="load_15m", key="load_15m",
name="Load (15m)", name="Load (15m)",
icon=CPU_ICON, icon=CPU_ICON,
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
"load_1m": SysMonitorSensorEntityDescription( "load_1m": SysMonitorSensorEntityDescription(
key="load_1m", key="load_1m",
name="Load (1m)", name="Load (1m)",
icon=CPU_ICON, icon=CPU_ICON,
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
"load_5m": SysMonitorSensorEntityDescription( "load_5m": SysMonitorSensorEntityDescription(
key="load_5m", key="load_5m",
name="Load (5m)", name="Load (5m)",
icon=CPU_ICON, icon=CPU_ICON,
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
"memory_free": SysMonitorSensorEntityDescription( "memory_free": SysMonitorSensorEntityDescription(
key="memory_free", key="memory_free",
name="Memory free", name="Memory free",
native_unit_of_measurement=DATA_MEBIBYTES, native_unit_of_measurement=DATA_MEBIBYTES,
icon="mdi:memory", icon="mdi:memory",
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
"memory_use": SysMonitorSensorEntityDescription( "memory_use": SysMonitorSensorEntityDescription(
key="memory_use", key="memory_use",
name="Memory use", name="Memory use",
native_unit_of_measurement=DATA_MEBIBYTES, native_unit_of_measurement=DATA_MEBIBYTES,
icon="mdi:memory", icon="mdi:memory",
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
"memory_use_percent": SysMonitorSensorEntityDescription( "memory_use_percent": SysMonitorSensorEntityDescription(
key="memory_use_percent", key="memory_use_percent",
name="Memory use (percent)", name="Memory use (percent)",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon="mdi:memory", icon="mdi:memory",
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
"network_in": SysMonitorSensorEntityDescription( "network_in": SysMonitorSensorEntityDescription(
key="network_in", key="network_in",
@ -187,7 +187,7 @@ SENSOR_TYPES: dict[str, SysMonitorSensorEntityDescription] = {
name="Network throughput in", name="Network throughput in",
native_unit_of_measurement=DATA_RATE_MEGABYTES_PER_SECOND, native_unit_of_measurement=DATA_RATE_MEGABYTES_PER_SECOND,
icon="mdi:server-network", icon="mdi:server-network",
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
mandatory_arg=True, mandatory_arg=True,
), ),
"throughput_network_out": SysMonitorSensorEntityDescription( "throughput_network_out": SysMonitorSensorEntityDescription(
@ -195,14 +195,14 @@ SENSOR_TYPES: dict[str, SysMonitorSensorEntityDescription] = {
name="Network throughput out", name="Network throughput out",
native_unit_of_measurement=DATA_RATE_MEGABYTES_PER_SECOND, native_unit_of_measurement=DATA_RATE_MEGABYTES_PER_SECOND,
icon="mdi:server-network", icon="mdi:server-network",
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
mandatory_arg=True, mandatory_arg=True,
), ),
"process": SysMonitorSensorEntityDescription( "process": SysMonitorSensorEntityDescription(
key="process", key="process",
name="Process", name="Process",
icon=CPU_ICON, icon=CPU_ICON,
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
mandatory_arg=True, mandatory_arg=True,
), ),
"processor_use": SysMonitorSensorEntityDescription( "processor_use": SysMonitorSensorEntityDescription(
@ -210,35 +210,35 @@ SENSOR_TYPES: dict[str, SysMonitorSensorEntityDescription] = {
name="Processor use", name="Processor use",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon=CPU_ICON, icon=CPU_ICON,
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
"processor_temperature": SysMonitorSensorEntityDescription( "processor_temperature": SysMonitorSensorEntityDescription(
key="processor_temperature", key="processor_temperature",
name="Processor temperature", name="Processor temperature",
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
"swap_free": SysMonitorSensorEntityDescription( "swap_free": SysMonitorSensorEntityDescription(
key="swap_free", key="swap_free",
name="Swap free", name="Swap free",
native_unit_of_measurement=DATA_MEBIBYTES, native_unit_of_measurement=DATA_MEBIBYTES,
icon="mdi:harddisk", icon="mdi:harddisk",
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
"swap_use": SysMonitorSensorEntityDescription( "swap_use": SysMonitorSensorEntityDescription(
key="swap_use", key="swap_use",
name="Swap use", name="Swap use",
native_unit_of_measurement=DATA_MEBIBYTES, native_unit_of_measurement=DATA_MEBIBYTES,
icon="mdi:harddisk", icon="mdi:harddisk",
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
"swap_use_percent": SysMonitorSensorEntityDescription( "swap_use_percent": SysMonitorSensorEntityDescription(
key="swap_use_percent", key="swap_use_percent",
name="Swap use (percent)", name="Swap use (percent)",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon="mdi:harddisk", icon="mdi:harddisk",
state_class=STATE_CLASS_TOTAL, state_class=STATE_CLASS_MEASUREMENT,
), ),
} }