From c8e06e2456b1d39cc638424fbb54ef1a17a4e0bc Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 7 Apr 2022 18:05:59 +0200 Subject: [PATCH] Use EntityFeature enums in lutron_caseta (#69588) --- homeassistant/components/lutron_caseta/cover.py | 15 +++++++-------- homeassistant/components/lutron_caseta/fan.py | 9 +++------ homeassistant/components/lutron_caseta/light.py | 4 ++-- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/homeassistant/components/lutron_caseta/cover.py b/homeassistant/components/lutron_caseta/cover.py index 68a7c16db1d..61c9c42a1b0 100644 --- a/homeassistant/components/lutron_caseta/cover.py +++ b/homeassistant/components/lutron_caseta/cover.py @@ -4,12 +4,9 @@ import logging from homeassistant.components.cover import ( ATTR_POSITION, DOMAIN, - SUPPORT_CLOSE, - SUPPORT_OPEN, - SUPPORT_SET_POSITION, - SUPPORT_STOP, CoverDeviceClass, CoverEntity, + CoverEntityFeature, ) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant @@ -47,10 +44,12 @@ async def async_setup_entry( class LutronCasetaCover(LutronCasetaDevice, CoverEntity): """Representation of a Lutron shade.""" - @property - def supported_features(self): - """Flag supported features.""" - return SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION + _attr_supported_features = ( + CoverEntityFeature.OPEN + | CoverEntityFeature.CLOSE + | CoverEntityFeature.STOP + | CoverEntityFeature.SET_POSITION + ) @property def is_closed(self): diff --git a/homeassistant/components/lutron_caseta/fan.py b/homeassistant/components/lutron_caseta/fan.py index cb00fa6f2c8..00236405735 100644 --- a/homeassistant/components/lutron_caseta/fan.py +++ b/homeassistant/components/lutron_caseta/fan.py @@ -5,7 +5,7 @@ import logging from pylutron_caseta import FAN_HIGH, FAN_LOW, FAN_MEDIUM, FAN_MEDIUM_HIGH, FAN_OFF -from homeassistant.components.fan import DOMAIN, SUPPORT_SET_SPEED, FanEntity +from homeassistant.components.fan import DOMAIN, FanEntity, FanEntityFeature from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -49,6 +49,8 @@ async def async_setup_entry( class LutronCasetaFan(LutronCasetaDevice, FanEntity): """Representation of a Lutron Caseta fan. Including Fan Speed.""" + _attr_supported_features = FanEntityFeature.SET_SPEED + @property def percentage(self) -> int | None: """Return the current speed percentage.""" @@ -65,11 +67,6 @@ class LutronCasetaFan(LutronCasetaDevice, FanEntity): """Return the number of speeds the fan supports.""" return len(ORDERED_NAMED_FAN_SPEEDS) - @property - def supported_features(self) -> int: - """Flag supported features. Speed Only.""" - return SUPPORT_SET_SPEED - async def async_turn_on( self, percentage: int = None, diff --git a/homeassistant/components/lutron_caseta/light.py b/homeassistant/components/lutron_caseta/light.py index 3e7a8725b1b..ecee6df5cc6 100644 --- a/homeassistant/components/lutron_caseta/light.py +++ b/homeassistant/components/lutron_caseta/light.py @@ -7,8 +7,8 @@ from homeassistant.components.light import ( ATTR_TRANSITION, COLOR_MODE_BRIGHTNESS, DOMAIN, - SUPPORT_TRANSITION, LightEntity, + LightEntityFeature, ) from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant @@ -58,7 +58,7 @@ class LutronCasetaLight(LutronCasetaDevice, LightEntity): _attr_color_mode = COLOR_MODE_BRIGHTNESS _attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS} - _attr_supported_features = SUPPORT_TRANSITION + _attr_supported_features = LightEntityFeature.TRANSITION @property def brightness(self):