Files
home-assistant-core/homeassistant/components/synology_dsm/const.py
T
MariusandQuentame a6a011ec19 Use entity_class 'safety' in synology_dsm storage sensors (#39757)
* Use entity_class: 'safety' in storage sensors

and more meaningful icons then 'mdi:test-tube', not sure if these are even necessary, given the device_class that defines the icons too?

* Set device_class, not icon

Still, the temperature sensors have both set, should I take these out in this go too? While we're at it....

* added device_class temperature to temp sensors

and removed explicit icons
do we need to set a D_c also on the Status sensor? line 187

* revert device_class Safety

which is now set in const.py
following up on https://github.com/home-assistant/core/pull/39757#pullrequestreview-483705147

* Use DEVICE_CLASS_SAFETY from const

+ revert temp to avoid conflict

* const from binary

* reverted non binary status sensors

to use: "mdi:checkbox-marked-circle-outline" and set None to device_class

Co-authored-by: Quentame <polletquentin74@me.com>
2020-09-10 09:21:51 +02:00

253 lines
7.4 KiB
Python

"""Constants for Synology DSM."""
from synology_dsm.api.core.security import SynoCoreSecurity
from synology_dsm.api.core.utilization import SynoCoreUtilization
from synology_dsm.api.storage.storage import SynoStorage
from homeassistant.components.binary_sensor import DEVICE_CLASS_SAFETY
from homeassistant.const import (
DATA_MEGABYTES,
DATA_RATE_KILOBYTES_PER_SECOND,
DATA_TERABYTES,
PERCENTAGE,
)
DOMAIN = "synology_dsm"
PLATFORMS = ["binary_sensor", "sensor"]
# Entry keys
SYNO_API = "syno_api"
UNDO_UPDATE_LISTENER = "undo_update_listener"
# Configuration
CONF_VOLUMES = "volumes"
DEFAULT_SSL = True
DEFAULT_PORT = 5000
DEFAULT_PORT_SSL = 5001
# Options
DEFAULT_SCAN_INTERVAL = 15 # min
ENTITY_NAME = "name"
ENTITY_UNIT = "unit"
ENTITY_ICON = "icon"
ENTITY_CLASS = "device_class"
ENTITY_ENABLE = "enable"
# Entity keys should start with the API_KEY to fetch
# Binary sensors
STORAGE_DISK_BINARY_SENSORS = {
f"{SynoStorage.API_KEY}:disk_exceed_bad_sector_thr": {
ENTITY_NAME: "Exceeded Max Bad Sectors",
ENTITY_UNIT: None,
ENTITY_ICON: None,
ENTITY_CLASS: DEVICE_CLASS_SAFETY,
ENTITY_ENABLE: True,
},
f"{SynoStorage.API_KEY}:disk_below_remain_life_thr": {
ENTITY_NAME: "Below Min Remaining Life",
ENTITY_UNIT: None,
ENTITY_ICON: None,
ENTITY_CLASS: DEVICE_CLASS_SAFETY,
ENTITY_ENABLE: True,
},
}
SECURITY_BINARY_SENSORS = {
f"{SynoCoreSecurity.API_KEY}:status": {
ENTITY_NAME: "Security status",
ENTITY_UNIT: None,
ENTITY_ICON: None,
ENTITY_CLASS: DEVICE_CLASS_SAFETY,
ENTITY_ENABLE: True,
},
}
# Sensors
UTILISATION_SENSORS = {
f"{SynoCoreUtilization.API_KEY}:cpu_other_load": {
ENTITY_NAME: "CPU Load (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_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_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_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_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_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_ICON: "mdi:chip",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoCoreUtilization.API_KEY}:memory_real_usage": {
ENTITY_NAME: "Memory Usage (Real)",
ENTITY_UNIT: PERCENTAGE,
ENTITY_ICON: "mdi:memory",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoCoreUtilization.API_KEY}:memory_size": {
ENTITY_NAME: "Memory Size",
ENTITY_UNIT: DATA_MEGABYTES,
ENTITY_ICON: "mdi:memory",
ENTITY_CLASS: None,
ENTITY_ENABLE: False,
},
f"{SynoCoreUtilization.API_KEY}:memory_cached": {
ENTITY_NAME: "Memory Cached",
ENTITY_UNIT: DATA_MEGABYTES,
ENTITY_ICON: "mdi:memory",
ENTITY_CLASS: None,
ENTITY_ENABLE: False,
},
f"{SynoCoreUtilization.API_KEY}:memory_available_swap": {
ENTITY_NAME: "Memory Available (Swap)",
ENTITY_UNIT: DATA_MEGABYTES,
ENTITY_ICON: "mdi:memory",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoCoreUtilization.API_KEY}:memory_available_real": {
ENTITY_NAME: "Memory Available (Real)",
ENTITY_UNIT: DATA_MEGABYTES,
ENTITY_ICON: "mdi:memory",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoCoreUtilization.API_KEY}:memory_total_swap": {
ENTITY_NAME: "Memory Total (Swap)",
ENTITY_UNIT: DATA_MEGABYTES,
ENTITY_ICON: "mdi:memory",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoCoreUtilization.API_KEY}:memory_total_real": {
ENTITY_NAME: "Memory Total (Real)",
ENTITY_UNIT: DATA_MEGABYTES,
ENTITY_ICON: "mdi:memory",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoCoreUtilization.API_KEY}:network_up": {
ENTITY_NAME: "Network Up",
ENTITY_UNIT: DATA_RATE_KILOBYTES_PER_SECOND,
ENTITY_ICON: "mdi:upload",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoCoreUtilization.API_KEY}:network_down": {
ENTITY_NAME: "Network Down",
ENTITY_UNIT: DATA_RATE_KILOBYTES_PER_SECOND,
ENTITY_ICON: "mdi:download",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
}
STORAGE_VOL_SENSORS = {
f"{SynoStorage.API_KEY}:volume_status": {
ENTITY_NAME: "Status",
ENTITY_UNIT: None,
ENTITY_ICON: "mdi:checkbox-marked-circle-outline",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoStorage.API_KEY}:volume_size_total": {
ENTITY_NAME: "Total Size",
ENTITY_UNIT: DATA_TERABYTES,
ENTITY_ICON: "mdi:chart-pie",
ENTITY_CLASS: None,
ENTITY_ENABLE: False,
},
f"{SynoStorage.API_KEY}:volume_size_used": {
ENTITY_NAME: "Used Space",
ENTITY_UNIT: DATA_TERABYTES,
ENTITY_ICON: "mdi:chart-pie",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoStorage.API_KEY}:volume_percentage_used": {
ENTITY_NAME: "Volume Used",
ENTITY_UNIT: PERCENTAGE,
ENTITY_ICON: "mdi:chart-pie",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoStorage.API_KEY}:volume_disk_temp_avg": {
ENTITY_NAME: "Average Disk Temp",
ENTITY_UNIT: None,
ENTITY_ICON: "mdi:thermometer",
ENTITY_CLASS: "temperature",
ENTITY_ENABLE: True,
},
f"{SynoStorage.API_KEY}:volume_disk_temp_max": {
ENTITY_NAME: "Maximum Disk Temp",
ENTITY_UNIT: None,
ENTITY_ICON: "mdi:thermometer",
ENTITY_CLASS: "temperature",
ENTITY_ENABLE: False,
},
}
STORAGE_DISK_SENSORS = {
f"{SynoStorage.API_KEY}:disk_smart_status": {
ENTITY_NAME: "Status (Smart)",
ENTITY_UNIT: None,
ENTITY_ICON: "mdi:checkbox-marked-circle-outline",
ENTITY_CLASS: None,
ENTITY_ENABLE: False,
},
f"{SynoStorage.API_KEY}:disk_status": {
ENTITY_NAME: "Status",
ENTITY_UNIT: None,
ENTITY_ICON: "mdi:checkbox-marked-circle-outline",
ENTITY_CLASS: None,
ENTITY_ENABLE: True,
},
f"{SynoStorage.API_KEY}:disk_temp": {
ENTITY_NAME: "Temperature",
ENTITY_UNIT: None,
ENTITY_ICON: "mdi:thermometer",
ENTITY_CLASS: "temperature",
ENTITY_ENABLE: True,
},
}
TEMP_SENSORS_KEYS = ["volume_disk_temp_avg", "volume_disk_temp_max", "disk_temp"]