From 76bdf9bc251669155545587b90a0e5c6f12897e9 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 9 Dec 2021 09:16:14 +0100 Subject: [PATCH] Use new DeviceClass enums in bosch_shc (#61324) Co-authored-by: epenet --- .../components/bosch_shc/binary_sensor.py | 16 +++++++--------- homeassistant/components/bosch_shc/cover.py | 4 ++-- homeassistant/components/bosch_shc/sensor.py | 14 +++++--------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/bosch_shc/binary_sensor.py b/homeassistant/components/bosch_shc/binary_sensor.py index 29e45ba2359..341be87a939 100644 --- a/homeassistant/components/bosch_shc/binary_sensor.py +++ b/homeassistant/components/bosch_shc/binary_sensor.py @@ -3,9 +3,7 @@ from boschshcpy import SHCBatteryDevice, SHCSession, SHCShutterContact from boschshcpy.device import SHCDevice from homeassistant.components.binary_sensor import ( - DEVICE_CLASS_BATTERY, - DEVICE_CLASS_DOOR, - DEVICE_CLASS_WINDOW, + BinarySensorDeviceClass, BinarySensorEntity, ) @@ -57,13 +55,13 @@ class ShutterContactSensor(SHCEntity, BinarySensorEntity): """Initialize an SHC shutter contact sensor..""" super().__init__(device, parent_id, entry_id) switcher = { - "ENTRANCE_DOOR": DEVICE_CLASS_DOOR, - "REGULAR_WINDOW": DEVICE_CLASS_WINDOW, - "FRENCH_WINDOW": DEVICE_CLASS_DOOR, - "GENERIC": DEVICE_CLASS_WINDOW, + "ENTRANCE_DOOR": BinarySensorDeviceClass.DOOR, + "REGULAR_WINDOW": BinarySensorDeviceClass.WINDOW, + "FRENCH_WINDOW": BinarySensorDeviceClass.DOOR, + "GENERIC": BinarySensorDeviceClass.WINDOW, } self._attr_device_class = switcher.get( - self._device.device_class, DEVICE_CLASS_WINDOW + self._device.device_class, BinarySensorDeviceClass.WINDOW ) @property @@ -75,7 +73,7 @@ class ShutterContactSensor(SHCEntity, BinarySensorEntity): class BatterySensor(SHCEntity, BinarySensorEntity): """Representation of an SHC battery reporting sensor.""" - _attr_device_class = DEVICE_CLASS_BATTERY + _attr_device_class = BinarySensorDeviceClass.BATTERY def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None: """Initialize an SHC battery reporting sensor.""" diff --git a/homeassistant/components/bosch_shc/cover.py b/homeassistant/components/bosch_shc/cover.py index 91543e586bf..c08984ca0c2 100644 --- a/homeassistant/components/bosch_shc/cover.py +++ b/homeassistant/components/bosch_shc/cover.py @@ -3,11 +3,11 @@ from boschshcpy import SHCSession, SHCShutterControl from homeassistant.components.cover import ( ATTR_POSITION, - DEVICE_CLASS_SHUTTER, SUPPORT_CLOSE, SUPPORT_OPEN, SUPPORT_SET_POSITION, SUPPORT_STOP, + CoverDeviceClass, CoverEntity, ) @@ -37,7 +37,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): class ShutterControlCover(SHCEntity, CoverEntity): """Representation of a SHC shutter control device.""" - _attr_device_class = DEVICE_CLASS_SHUTTER + _attr_device_class = CoverDeviceClass.SHUTTER _attr_supported_features = ( SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION ) diff --git a/homeassistant/components/bosch_shc/sensor.py b/homeassistant/components/bosch_shc/sensor.py index 6ea4f3c7065..33d18ebbfd4 100644 --- a/homeassistant/components/bosch_shc/sensor.py +++ b/homeassistant/components/bosch_shc/sensor.py @@ -2,13 +2,9 @@ from boschshcpy import SHCSession from boschshcpy.device import SHCDevice -from homeassistant.components.sensor import SensorEntity +from homeassistant.components.sensor import SensorDeviceClass, SensorEntity from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, - DEVICE_CLASS_ENERGY, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_POWER, - DEVICE_CLASS_TEMPERATURE, ENERGY_KILO_WATT_HOUR, PERCENTAGE, POWER_WATT, @@ -146,7 +142,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): class TemperatureSensor(SHCEntity, SensorEntity): """Representation of an SHC temperature reporting sensor.""" - _attr_device_class = DEVICE_CLASS_TEMPERATURE + _attr_device_class = SensorDeviceClass.TEMPERATURE _attr_native_unit_of_measurement = TEMP_CELSIUS def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None: @@ -164,7 +160,7 @@ class TemperatureSensor(SHCEntity, SensorEntity): class HumiditySensor(SHCEntity, SensorEntity): """Representation of an SHC humidity reporting sensor.""" - _attr_device_class = DEVICE_CLASS_HUMIDITY + _attr_device_class = SensorDeviceClass.HUMIDITY _attr_native_unit_of_measurement = PERCENTAGE def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None: @@ -267,7 +263,7 @@ class PurityRatingSensor(SHCEntity, SensorEntity): class PowerSensor(SHCEntity, SensorEntity): """Representation of an SHC power reporting sensor.""" - _attr_device_class = DEVICE_CLASS_POWER + _attr_device_class = SensorDeviceClass.POWER _attr_native_unit_of_measurement = POWER_WATT def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None: @@ -285,7 +281,7 @@ class PowerSensor(SHCEntity, SensorEntity): class EnergySensor(SHCEntity, SensorEntity): """Representation of an SHC energy reporting sensor.""" - _attr_device_class = DEVICE_CLASS_ENERGY + _attr_device_class = SensorDeviceClass.ENERGY _attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None: