Use new enums in systemmonitor (#62401)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-20 17:15:30 +01:00 committed by GitHub
parent 23baf6e02a
commit 071e29bf1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,10 +16,10 @@ import voluptuous as vol
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
STATE_CLASS_MEASUREMENT, SensorDeviceClass,
STATE_CLASS_TOTAL_INCREASING,
SensorEntity, SensorEntity,
SensorEntityDescription, SensorEntityDescription,
SensorStateClass,
) )
from homeassistant.const import ( from homeassistant.const import (
CONF_RESOURCES, CONF_RESOURCES,
@ -28,8 +28,6 @@ from homeassistant.const import (
DATA_GIBIBYTES, DATA_GIBIBYTES,
DATA_MEBIBYTES, DATA_MEBIBYTES,
DATA_RATE_MEGABYTES_PER_SECOND, DATA_RATE_MEGABYTES_PER_SECOND,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_TIMESTAMP,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
PERCENTAGE, PERCENTAGE,
STATE_OFF, STATE_OFF,
@ -80,21 +78,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_MEASUREMENT, state_class=SensorStateClass.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_MEASUREMENT, state_class=SensorStateClass.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_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
"ipv4_address": SysMonitorSensorEntityDescription( "ipv4_address": SysMonitorSensorEntityDescription(
key="ipv4_address", key="ipv4_address",
@ -111,53 +109,53 @@ SENSOR_TYPES: dict[str, SysMonitorSensorEntityDescription] = {
"last_boot": SysMonitorSensorEntityDescription( "last_boot": SysMonitorSensorEntityDescription(
key="last_boot", key="last_boot",
name="Last boot", name="Last boot",
device_class=DEVICE_CLASS_TIMESTAMP, device_class=SensorDeviceClass.TIMESTAMP,
), ),
"load_15m": SysMonitorSensorEntityDescription( "load_15m": SysMonitorSensorEntityDescription(
key="load_15m", key="load_15m",
name="Load (15m)", name="Load (15m)",
icon=CPU_ICON, icon=CPU_ICON,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.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_MEASUREMENT, state_class=SensorStateClass.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_MEASUREMENT, state_class=SensorStateClass.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_MEASUREMENT, state_class=SensorStateClass.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_MEASUREMENT, state_class=SensorStateClass.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_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
"network_in": SysMonitorSensorEntityDescription( "network_in": SysMonitorSensorEntityDescription(
key="network_in", key="network_in",
name="Network in", name="Network in",
native_unit_of_measurement=DATA_MEBIBYTES, native_unit_of_measurement=DATA_MEBIBYTES,
icon="mdi:server-network", icon="mdi:server-network",
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
mandatory_arg=True, mandatory_arg=True,
), ),
"network_out": SysMonitorSensorEntityDescription( "network_out": SysMonitorSensorEntityDescription(
@ -165,21 +163,21 @@ SENSOR_TYPES: dict[str, SysMonitorSensorEntityDescription] = {
name="Network out", name="Network out",
native_unit_of_measurement=DATA_MEBIBYTES, native_unit_of_measurement=DATA_MEBIBYTES,
icon="mdi:server-network", icon="mdi:server-network",
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
mandatory_arg=True, mandatory_arg=True,
), ),
"packets_in": SysMonitorSensorEntityDescription( "packets_in": SysMonitorSensorEntityDescription(
key="packets_in", key="packets_in",
name="Packets in", name="Packets in",
icon="mdi:server-network", icon="mdi:server-network",
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
mandatory_arg=True, mandatory_arg=True,
), ),
"packets_out": SysMonitorSensorEntityDescription( "packets_out": SysMonitorSensorEntityDescription(
key="packets_out", key="packets_out",
name="Packets out", name="Packets out",
icon="mdi:server-network", icon="mdi:server-network",
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
mandatory_arg=True, mandatory_arg=True,
), ),
"throughput_network_in": SysMonitorSensorEntityDescription( "throughput_network_in": SysMonitorSensorEntityDescription(
@ -187,7 +185,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_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
mandatory_arg=True, mandatory_arg=True,
), ),
"throughput_network_out": SysMonitorSensorEntityDescription( "throughput_network_out": SysMonitorSensorEntityDescription(
@ -195,14 +193,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_MEASUREMENT, state_class=SensorStateClass.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_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
mandatory_arg=True, mandatory_arg=True,
), ),
"processor_use": SysMonitorSensorEntityDescription( "processor_use": SysMonitorSensorEntityDescription(
@ -210,35 +208,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_MEASUREMENT, state_class=SensorStateClass.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=SensorDeviceClass.TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.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_MEASUREMENT, state_class=SensorStateClass.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_MEASUREMENT, state_class=SensorStateClass.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_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
} }