From bb538a9782de07090971122f2273d2bd5f68efee Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 16 Dec 2021 22:47:23 +0100 Subject: [PATCH] Use new enums in motion_blinds (#61931) --- .../components/motion_blinds/cover.py | 41 ++++++++----------- .../components/motion_blinds/sensor.py | 13 ++---- 2 files changed, 22 insertions(+), 32 deletions(-) diff --git a/homeassistant/components/motion_blinds/cover.py b/homeassistant/components/motion_blinds/cover.py index ad846e2f690..495c2f7078a 100644 --- a/homeassistant/components/motion_blinds/cover.py +++ b/homeassistant/components/motion_blinds/cover.py @@ -8,12 +8,7 @@ import voluptuous as vol from homeassistant.components.cover import ( ATTR_POSITION, ATTR_TILT_POSITION, - DEVICE_CLASS_AWNING, - DEVICE_CLASS_BLIND, - DEVICE_CLASS_CURTAIN, - DEVICE_CLASS_GATE, - DEVICE_CLASS_SHADE, - DEVICE_CLASS_SHUTTER, + CoverDeviceClass, CoverEntity, ) from homeassistant.helpers import config_validation as cv, entity_platform @@ -35,29 +30,29 @@ _LOGGER = logging.getLogger(__name__) POSITION_DEVICE_MAP = { - BlindType.RollerBlind: DEVICE_CLASS_SHADE, - BlindType.RomanBlind: DEVICE_CLASS_SHADE, - BlindType.HoneycombBlind: DEVICE_CLASS_SHADE, - BlindType.DimmingBlind: DEVICE_CLASS_SHADE, - BlindType.DayNightBlind: DEVICE_CLASS_SHADE, - BlindType.RollerShutter: DEVICE_CLASS_SHUTTER, - BlindType.Switch: DEVICE_CLASS_SHUTTER, - BlindType.RollerGate: DEVICE_CLASS_GATE, - BlindType.Awning: DEVICE_CLASS_AWNING, - BlindType.Curtain: DEVICE_CLASS_CURTAIN, - BlindType.CurtainLeft: DEVICE_CLASS_CURTAIN, - BlindType.CurtainRight: DEVICE_CLASS_CURTAIN, + BlindType.RollerBlind: CoverDeviceClass.SHADE, + BlindType.RomanBlind: CoverDeviceClass.SHADE, + BlindType.HoneycombBlind: CoverDeviceClass.SHADE, + BlindType.DimmingBlind: CoverDeviceClass.SHADE, + BlindType.DayNightBlind: CoverDeviceClass.SHADE, + BlindType.RollerShutter: CoverDeviceClass.SHUTTER, + BlindType.Switch: CoverDeviceClass.SHUTTER, + BlindType.RollerGate: CoverDeviceClass.GATE, + BlindType.Awning: CoverDeviceClass.AWNING, + BlindType.Curtain: CoverDeviceClass.CURTAIN, + BlindType.CurtainLeft: CoverDeviceClass.CURTAIN, + BlindType.CurtainRight: CoverDeviceClass.CURTAIN, } TILT_DEVICE_MAP = { - BlindType.VenetianBlind: DEVICE_CLASS_BLIND, - BlindType.ShangriLaBlind: DEVICE_CLASS_BLIND, - BlindType.DoubleRoller: DEVICE_CLASS_SHADE, - BlindType.VerticalBlind: DEVICE_CLASS_BLIND, + BlindType.VenetianBlind: CoverDeviceClass.BLIND, + BlindType.ShangriLaBlind: CoverDeviceClass.BLIND, + BlindType.DoubleRoller: CoverDeviceClass.SHADE, + BlindType.VerticalBlind: CoverDeviceClass.BLIND, } TDBU_DEVICE_MAP = { - BlindType.TopDownBottomUp: DEVICE_CLASS_SHADE, + BlindType.TopDownBottomUp: CoverDeviceClass.SHADE, } diff --git a/homeassistant/components/motion_blinds/sensor.py b/homeassistant/components/motion_blinds/sensor.py index c46798d81bf..126c1607864 100644 --- a/homeassistant/components/motion_blinds/sensor.py +++ b/homeassistant/components/motion_blinds/sensor.py @@ -1,13 +1,8 @@ """Support for Motion Blinds sensors.""" from motionblinds import BlindType -from homeassistant.components.sensor import SensorEntity -from homeassistant.const import ( - DEVICE_CLASS_BATTERY, - DEVICE_CLASS_SIGNAL_STRENGTH, - PERCENTAGE, - SIGNAL_STRENGTH_DECIBELS_MILLIWATT, -) +from homeassistant.components.sensor import SensorDeviceClass, SensorEntity +from homeassistant.const import PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -43,7 +38,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): class MotionBatterySensor(CoordinatorEntity, SensorEntity): """Representation of a Motion Battery Sensor.""" - _attr_device_class = DEVICE_CLASS_BATTERY + _attr_device_class = SensorDeviceClass.BATTERY _attr_native_unit_of_measurement = PERCENTAGE def __init__(self, coordinator, blind): @@ -119,7 +114,7 @@ class MotionTDBUBatterySensor(MotionBatterySensor): class MotionSignalStrengthSensor(CoordinatorEntity, SensorEntity): """Representation of a Motion Signal Strength Sensor.""" - _attr_device_class = DEVICE_CLASS_SIGNAL_STRENGTH + _attr_device_class = SensorDeviceClass.SIGNAL_STRENGTH _attr_entity_registry_enabled_default = False _attr_native_unit_of_measurement = SIGNAL_STRENGTH_DECIBELS_MILLIWATT