From a6a011ec196d7213521bd2d4a839b200d749a225 Mon Sep 17 00:00:00 2001 From: Marius <33354141+Mariusthvdb@users.noreply.github.com> Date: Thu, 10 Sep 2020 09:21:51 +0200 Subject: [PATCH] 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 --- .../components/synology_dsm/binary_sensor.py | 12 +----------- homeassistant/components/synology_dsm/const.py | 13 +++++++------ 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/synology_dsm/binary_sensor.py b/homeassistant/components/synology_dsm/binary_sensor.py index c95b4298f5d..a75f57db678 100644 --- a/homeassistant/components/synology_dsm/binary_sensor.py +++ b/homeassistant/components/synology_dsm/binary_sensor.py @@ -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 diff --git a/homeassistant/components/synology_dsm/const.py b/homeassistant/components/synology_dsm/const.py index 163561d13a0..2816ae681a1 100644 --- a/homeassistant/components/synology_dsm/const.py +++ b/homeassistant/components/synology_dsm/const.py @@ -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, }, }