Use EntityFeature enums in lutron_caseta (#69588)

This commit is contained in:
epenet 2022-04-07 18:05:59 +02:00 committed by GitHub
parent 62b6d03321
commit c8e06e2456
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 16 deletions

View File

@ -4,12 +4,9 @@ import logging
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
DOMAIN, DOMAIN,
SUPPORT_CLOSE,
SUPPORT_OPEN,
SUPPORT_SET_POSITION,
SUPPORT_STOP,
CoverDeviceClass, CoverDeviceClass,
CoverEntity, CoverEntity,
CoverEntityFeature,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -47,10 +44,12 @@ async def async_setup_entry(
class LutronCasetaCover(LutronCasetaDevice, CoverEntity): class LutronCasetaCover(LutronCasetaDevice, CoverEntity):
"""Representation of a Lutron shade.""" """Representation of a Lutron shade."""
@property _attr_supported_features = (
def supported_features(self): CoverEntityFeature.OPEN
"""Flag supported features.""" | CoverEntityFeature.CLOSE
return SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION | CoverEntityFeature.STOP
| CoverEntityFeature.SET_POSITION
)
@property @property
def is_closed(self): def is_closed(self):

View File

@ -5,7 +5,7 @@ import logging
from pylutron_caseta import FAN_HIGH, FAN_LOW, FAN_MEDIUM, FAN_MEDIUM_HIGH, FAN_OFF 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.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -49,6 +49,8 @@ async def async_setup_entry(
class LutronCasetaFan(LutronCasetaDevice, FanEntity): class LutronCasetaFan(LutronCasetaDevice, FanEntity):
"""Representation of a Lutron Caseta fan. Including Fan Speed.""" """Representation of a Lutron Caseta fan. Including Fan Speed."""
_attr_supported_features = FanEntityFeature.SET_SPEED
@property @property
def percentage(self) -> int | None: def percentage(self) -> int | None:
"""Return the current speed percentage.""" """Return the current speed percentage."""
@ -65,11 +67,6 @@ class LutronCasetaFan(LutronCasetaDevice, FanEntity):
"""Return the number of speeds the fan supports.""" """Return the number of speeds the fan supports."""
return len(ORDERED_NAMED_FAN_SPEEDS) 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( async def async_turn_on(
self, self,
percentage: int = None, percentage: int = None,

View File

@ -7,8 +7,8 @@ from homeassistant.components.light import (
ATTR_TRANSITION, ATTR_TRANSITION,
COLOR_MODE_BRIGHTNESS, COLOR_MODE_BRIGHTNESS,
DOMAIN, DOMAIN,
SUPPORT_TRANSITION,
LightEntity, LightEntity,
LightEntityFeature,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -58,7 +58,7 @@ class LutronCasetaLight(LutronCasetaDevice, LightEntity):
_attr_color_mode = COLOR_MODE_BRIGHTNESS _attr_color_mode = COLOR_MODE_BRIGHTNESS
_attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS} _attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
_attr_supported_features = SUPPORT_TRANSITION _attr_supported_features = LightEntityFeature.TRANSITION
@property @property
def brightness(self): def brightness(self):