Use new enums in synology_dsm (#62398)

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/62393/head^2
epenet 2021-12-20 16:53:21 +01:00 committed by GitHub
parent e2a95181ad
commit e5cf9b78bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 41 additions and 45 deletions

View File

@ -11,28 +11,24 @@ from synology_dsm.api.storage.storage import SynoStorage
from synology_dsm.api.surveillance_station import SynoSurveillanceStation
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_SAFETY,
DEVICE_CLASS_UPDATE,
BinarySensorDeviceClass,
BinarySensorEntityDescription,
)
from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT,
SensorDeviceClass,
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.components.switch import SwitchEntityDescription
from homeassistant.const import (
DATA_MEGABYTES,
DATA_RATE_KILOBYTES_PER_SECOND,
DATA_TERABYTES,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_TIMESTAMP,
ENTITY_CATEGORY_CONFIG,
ENTITY_CATEGORY_DIAGNOSTIC,
PERCENTAGE,
TEMP_CELSIUS,
Platform,
)
from homeassistant.helpers.entity import EntityDescription
from homeassistant.helpers.entity import EntityCategory, EntityDescription
DOMAIN = "synology_dsm"
PLATFORMS = [Platform.BINARY_SENSOR, Platform.CAMERA, Platform.SENSOR, Platform.SWITCH]
@ -110,8 +106,8 @@ UPGRADE_BINARY_SENSORS: tuple[SynologyDSMBinarySensorEntityDescription, ...] = (
api_key=SynoCoreUpgrade.API_KEY,
key="update_available",
name="Update Available",
device_class=DEVICE_CLASS_UPDATE,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
device_class=BinarySensorDeviceClass.UPDATE,
entity_category=EntityCategory.DIAGNOSTIC,
),
)
@ -120,7 +116,7 @@ SECURITY_BINARY_SENSORS: tuple[SynologyDSMBinarySensorEntityDescription, ...] =
api_key=SynoCoreSecurity.API_KEY,
key="status",
name="Security Status",
device_class=DEVICE_CLASS_SAFETY,
device_class=BinarySensorDeviceClass.SAFETY,
),
)
@ -129,15 +125,15 @@ STORAGE_DISK_BINARY_SENSORS: tuple[SynologyDSMBinarySensorEntityDescription, ...
api_key=SynoStorage.API_KEY,
key="disk_exceed_bad_sector_thr",
name="Exceeded Max Bad Sectors",
device_class=DEVICE_CLASS_SAFETY,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
device_class=BinarySensorDeviceClass.SAFETY,
entity_category=EntityCategory.DIAGNOSTIC,
),
SynologyDSMBinarySensorEntityDescription(
api_key=SynoStorage.API_KEY,
key="disk_below_remain_life_thr",
name="Below Min Remaining Life",
device_class=DEVICE_CLASS_SAFETY,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
device_class=BinarySensorDeviceClass.SAFETY,
entity_category=EntityCategory.DIAGNOSTIC,
),
)
@ -150,7 +146,7 @@ UTILISATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
native_unit_of_measurement=PERCENTAGE,
icon="mdi:chip",
entity_registry_enabled_default=False,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoCoreUtilization.API_KEY,
@ -158,7 +154,7 @@ UTILISATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
name="CPU Utilization (User)",
native_unit_of_measurement=PERCENTAGE,
icon="mdi:chip",
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoCoreUtilization.API_KEY,
@ -167,7 +163,7 @@ UTILISATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
native_unit_of_measurement=PERCENTAGE,
icon="mdi:chip",
entity_registry_enabled_default=False,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoCoreUtilization.API_KEY,
@ -175,7 +171,7 @@ UTILISATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
name="CPU Utilization (Total)",
native_unit_of_measurement=PERCENTAGE,
icon="mdi:chip",
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoCoreUtilization.API_KEY,
@ -205,7 +201,7 @@ UTILISATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
name="Memory Usage (Real)",
native_unit_of_measurement=PERCENTAGE,
icon="mdi:memory",
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoCoreUtilization.API_KEY,
@ -214,7 +210,7 @@ UTILISATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
native_unit_of_measurement=DATA_MEGABYTES,
icon="mdi:memory",
entity_registry_enabled_default=False,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoCoreUtilization.API_KEY,
@ -223,7 +219,7 @@ UTILISATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
native_unit_of_measurement=DATA_MEGABYTES,
icon="mdi:memory",
entity_registry_enabled_default=False,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoCoreUtilization.API_KEY,
@ -231,7 +227,7 @@ UTILISATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
name="Memory Available (Swap)",
native_unit_of_measurement=DATA_MEGABYTES,
icon="mdi:memory",
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoCoreUtilization.API_KEY,
@ -239,7 +235,7 @@ UTILISATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
name="Memory Available (Real)",
native_unit_of_measurement=DATA_MEGABYTES,
icon="mdi:memory",
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoCoreUtilization.API_KEY,
@ -247,7 +243,7 @@ UTILISATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
name="Memory Total (Swap)",
native_unit_of_measurement=DATA_MEGABYTES,
icon="mdi:memory",
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoCoreUtilization.API_KEY,
@ -255,7 +251,7 @@ UTILISATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
name="Memory Total (Real)",
native_unit_of_measurement=DATA_MEGABYTES,
icon="mdi:memory",
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoCoreUtilization.API_KEY,
@ -263,7 +259,7 @@ UTILISATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
name="Upload Throughput",
native_unit_of_measurement=DATA_RATE_KILOBYTES_PER_SECOND,
icon="mdi:upload",
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoCoreUtilization.API_KEY,
@ -271,7 +267,7 @@ UTILISATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
name="Download Throughput",
native_unit_of_measurement=DATA_RATE_KILOBYTES_PER_SECOND,
icon="mdi:download",
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
)
STORAGE_VOL_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
@ -288,7 +284,7 @@ STORAGE_VOL_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
native_unit_of_measurement=DATA_TERABYTES,
icon="mdi:chart-pie",
entity_registry_enabled_default=False,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoStorage.API_KEY,
@ -296,7 +292,7 @@ STORAGE_VOL_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
name="Used Space",
native_unit_of_measurement=DATA_TERABYTES,
icon="mdi:chart-pie",
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SynologyDSMSensorEntityDescription(
api_key=SynoStorage.API_KEY,
@ -310,17 +306,17 @@ STORAGE_VOL_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
key="volume_disk_temp_avg",
name="Average Disk Temp",
native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC,
),
SynologyDSMSensorEntityDescription(
api_key=SynoStorage.API_KEY,
key="volume_disk_temp_max",
name="Maximum Disk Temp",
native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE,
device_class=SensorDeviceClass.TEMPERATURE,
entity_registry_enabled_default=False,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
entity_category=EntityCategory.DIAGNOSTIC,
),
)
STORAGE_DISK_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
@ -330,23 +326,23 @@ STORAGE_DISK_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
name="Status (Smart)",
icon="mdi:checkbox-marked-circle-outline",
entity_registry_enabled_default=False,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
entity_category=EntityCategory.DIAGNOSTIC,
),
SynologyDSMSensorEntityDescription(
api_key=SynoStorage.API_KEY,
key="disk_status",
name="Status",
icon="mdi:checkbox-marked-circle-outline",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
entity_category=EntityCategory.DIAGNOSTIC,
),
SynologyDSMSensorEntityDescription(
api_key=SynoStorage.API_KEY,
key="disk_temp",
name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
),
)
@ -356,17 +352,17 @@ INFORMATION_SENSORS: tuple[SynologyDSMSensorEntityDescription, ...] = (
key="temperature",
name="Temperature",
native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC,
),
SynologyDSMSensorEntityDescription(
api_key=SynoDSMInformation.API_KEY,
key="uptime",
name="Last Boot",
device_class=DEVICE_CLASS_TIMESTAMP,
device_class=SensorDeviceClass.TIMESTAMP,
entity_registry_enabled_default=False,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
entity_category=EntityCategory.DIAGNOSTIC,
),
)
@ -377,6 +373,6 @@ SURVEILLANCE_SWITCH: tuple[SynologyDSMSwitchEntityDescription, ...] = (
key="home_mode",
name="Home Mode",
icon="mdi:home-account",
entity_category=ENTITY_CATEGORY_CONFIG,
entity_category=EntityCategory.CONFIG,
),
)