Correct synology_dsm CPU sensor's naming and measurement unit (#45500)

This commit is contained in:
Michael 2021-02-01 18:15:34 +01:00 committed by GitHub
parent 285bd3aa91
commit c90588d35d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 10 deletions

View File

@ -37,6 +37,7 @@ DEFAULT_PORT_SSL = 5001
DEFAULT_SCAN_INTERVAL = 15 # min
DEFAULT_TIMEOUT = 10 # sec
ENTITY_UNIT_LOAD = "load"
ENTITY_NAME = "name"
ENTITY_UNIT = "unit"
@ -95,50 +96,50 @@ STORAGE_DISK_BINARY_SENSORS = {
# Sensors
UTILISATION_SENSORS = {
f"{SynoCoreUtilization.API_KEY}:cpu_other_load": {
ENTITY_NAME: "CPU Load (Other)",
ENTITY_NAME: "CPU Utilization (Other)",
ENTITY_UNIT: PERCENTAGE,
ENTITY_ICON: "mdi:chip",
ENTITY_CLASS: None,
ENTITY_ENABLE: False,
},
f"{SynoCoreUtilization.API_KEY}:cpu_user_load": {
ENTITY_NAME: "CPU Load (User)",
ENTITY_NAME: "CPU Utilization (User)",
ENTITY_UNIT: PERCENTAGE,
ENTITY_ICON: "mdi:chip",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoCoreUtilization.API_KEY}:cpu_system_load": {
ENTITY_NAME: "CPU Load (System)",
ENTITY_NAME: "CPU Utilization (System)",
ENTITY_UNIT: PERCENTAGE,
ENTITY_ICON: "mdi:chip",
ENTITY_CLASS: None,
ENTITY_ENABLE: False,
},
f"{SynoCoreUtilization.API_KEY}:cpu_total_load": {
ENTITY_NAME: "CPU Load (Total)",
ENTITY_NAME: "CPU Utilization (Total)",
ENTITY_UNIT: PERCENTAGE,
ENTITY_ICON: "mdi:chip",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoCoreUtilization.API_KEY}:cpu_1min_load": {
ENTITY_NAME: "CPU Load (1 min)",
ENTITY_UNIT: PERCENTAGE,
ENTITY_NAME: "CPU Load Averarge (1 min)",
ENTITY_UNIT: ENTITY_UNIT_LOAD,
ENTITY_ICON: "mdi:chip",
ENTITY_CLASS: None,
ENTITY_ENABLE: False,
},
f"{SynoCoreUtilization.API_KEY}:cpu_5min_load": {
ENTITY_NAME: "CPU Load (5 min)",
ENTITY_UNIT: PERCENTAGE,
ENTITY_NAME: "CPU Load Averarge (5 min)",
ENTITY_UNIT: ENTITY_UNIT_LOAD,
ENTITY_ICON: "mdi:chip",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoCoreUtilization.API_KEY}:cpu_15min_load": {
ENTITY_NAME: "CPU Load (15 min)",
ENTITY_UNIT: PERCENTAGE,
ENTITY_NAME: "CPU Load Averarge (15 min)",
ENTITY_UNIT: ENTITY_UNIT_LOAD,
ENTITY_ICON: "mdi:chip",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,

View File

@ -19,6 +19,7 @@ from . import SynoApi, SynologyDSMDeviceEntity, SynologyDSMDispatcherEntity
from .const import (
CONF_VOLUMES,
DOMAIN,
ENTITY_UNIT_LOAD,
INFORMATION_SENSORS,
STORAGE_DISK_SENSORS,
STORAGE_VOL_SENSORS,
@ -88,6 +89,10 @@ class SynoDSMUtilSensor(SynologyDSMDispatcherEntity):
if self._unit == DATA_RATE_KILOBYTES_PER_SECOND:
return round(attr / 1024.0, 1)
# CPU load average
if self._unit == ENTITY_UNIT_LOAD:
return round(attr / 100, 2)
return attr
@property