mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
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>
This commit is contained in:
parent
b57f97b954
commit
a6a011ec19
@ -1,10 +1,7 @@
|
||||
"""Support for Synology DSM binary sensors."""
|
||||
from typing import Dict
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_SAFETY,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_DISKS
|
||||
from homeassistant.helpers.typing import HomeAssistantType
|
||||
@ -17,8 +14,6 @@ from .const import (
|
||||
SYNO_API,
|
||||
)
|
||||
|
||||
DEFAULT_DEVICE_CLASS = DEVICE_CLASS_SAFETY
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
|
||||
@ -76,8 +71,3 @@ class SynoDSMStorageBinarySensor(SynologyDSMDeviceEntity, BinarySensorEntity):
|
||||
if attr is None:
|
||||
return None
|
||||
return attr
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the device class of this binary sensor."""
|
||||
return DEFAULT_DEVICE_CLASS
|
||||
|
@ -4,6 +4,7 @@ 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,
|
||||
@ -41,15 +42,15 @@ STORAGE_DISK_BINARY_SENSORS = {
|
||||
f"{SynoStorage.API_KEY}:disk_exceed_bad_sector_thr": {
|
||||
ENTITY_NAME: "Exceeded Max Bad Sectors",
|
||||
ENTITY_UNIT: None,
|
||||
ENTITY_ICON: "mdi:test-tube",
|
||||
ENTITY_CLASS: 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: "mdi:test-tube",
|
||||
ENTITY_CLASS: None,
|
||||
ENTITY_ICON: None,
|
||||
ENTITY_CLASS: DEVICE_CLASS_SAFETY,
|
||||
ENTITY_ENABLE: True,
|
||||
},
|
||||
}
|
||||
@ -58,8 +59,8 @@ SECURITY_BINARY_SENSORS = {
|
||||
f"{SynoCoreSecurity.API_KEY}:status": {
|
||||
ENTITY_NAME: "Security status",
|
||||
ENTITY_UNIT: None,
|
||||
ENTITY_ICON: "mdi:checkbox-marked-circle-outline",
|
||||
ENTITY_CLASS: "safety",
|
||||
ENTITY_ICON: None,
|
||||
ENTITY_CLASS: DEVICE_CLASS_SAFETY,
|
||||
ENTITY_ENABLE: True,
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user