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 (
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):

View file

@ -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,

View file

@ -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):