Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 41 additions & 45 deletions homeassistant/components/synology_dsm/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,24 @@
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]
Expand Down Expand Up @@ -110,8 +106,8 @@ class SynologyDSMSwitchEntityDescription(
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,
),
)

Expand All @@ -120,7 +116,7 @@ class SynologyDSMSwitchEntityDescription(
api_key=SynoCoreSecurity.API_KEY,
key="status",
name="Security Status",
device_class=DEVICE_CLASS_SAFETY,
device_class=BinarySensorDeviceClass.SAFETY,
),
)

Expand All @@ -129,15 +125,15 @@ class SynologyDSMSwitchEntityDescription(
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,
),
)

Expand All @@ -150,15 +146,15 @@ class SynologyDSMSwitchEntityDescription(
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,
key="cpu_user_load",
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,
Expand All @@ -167,15 +163,15 @@ class SynologyDSMSwitchEntityDescription(
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,
key="cpu_total_load",
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,
Expand Down Expand Up @@ -205,7 +201,7 @@ class SynologyDSMSwitchEntityDescription(
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,
Expand All @@ -214,7 +210,7 @@ class SynologyDSMSwitchEntityDescription(
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,
Expand All @@ -223,55 +219,55 @@ class SynologyDSMSwitchEntityDescription(
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,
key="memory_available_swap",
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,
key="memory_available_real",
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,
key="memory_total_swap",
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,
key="memory_total_real",
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,
key="network_up",
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,
key="network_down",
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, ...] = (
Expand All @@ -288,15 +284,15 @@ class SynologyDSMSwitchEntityDescription(
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,
key="volume_size_used",
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,
Expand All @@ -310,17 +306,17 @@ class SynologyDSMSwitchEntityDescription(
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, ...] = (
Expand All @@ -330,23 +326,23 @@ class SynologyDSMSwitchEntityDescription(
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,
),
)

Expand All @@ -356,17 +352,17 @@ class SynologyDSMSwitchEntityDescription(
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,
),
)

Expand All @@ -377,6 +373,6 @@ class SynologyDSMSwitchEntityDescription(
key="home_mode",
name="Home Mode",
icon="mdi:home-account",
entity_category=ENTITY_CATEGORY_CONFIG,
entity_category=EntityCategory.CONFIG,
),
)