Migrate yeelightsunflower light to ColorMode (#70852)

This commit is contained in:
epenet 2022-04-27 09:49:20 +02:00 committed by GitHub
parent 4e6043e05e
commit 4a46fd9559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,8 +10,7 @@ from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_HS_COLOR,
PLATFORM_SCHEMA,
SUPPORT_BRIGHTNESS,
SUPPORT_COLOR,
ColorMode,
LightEntity,
)
from homeassistant.const import CONF_HOST
@ -23,8 +22,6 @@ import homeassistant.util.color as color_util
_LOGGER = logging.getLogger(__name__)
SUPPORT_YEELIGHT_SUNFLOWER = SUPPORT_BRIGHTNESS | SUPPORT_COLOR
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_HOST): cv.string})
@ -48,6 +45,9 @@ def setup_platform(
class SunflowerBulb(LightEntity):
"""Representation of a Yeelight Sunflower Light."""
_attr_color_mode = ColorMode.HS
_attr_supported_color_modes = {ColorMode.HS}
def __init__(self, light):
"""Initialize a Yeelight Sunflower bulb."""
self._light = light
@ -87,11 +87,6 @@ class SunflowerBulb(LightEntity):
"""Return the color property."""
return color_util.color_RGB_to_hs(*self._rgb_color)
@property
def supported_features(self):
"""Flag supported features."""
return SUPPORT_YEELIGHT_SUNFLOWER
def turn_on(self, **kwargs):
"""Instruct the light to turn on, optionally set colour/brightness."""
# when no arguments, just turn light on (full brightness)