mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Migrate yeelightsunflower light to ColorMode (#70852)
This commit is contained in:
parent
4e6043e05e
commit
4a46fd9559
@ -10,8 +10,7 @@ from homeassistant.components.light import (
|
|||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_HS_COLOR,
|
ATTR_HS_COLOR,
|
||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
SUPPORT_BRIGHTNESS,
|
ColorMode,
|
||||||
SUPPORT_COLOR,
|
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_HOST
|
from homeassistant.const import CONF_HOST
|
||||||
@ -23,8 +22,6 @@ import homeassistant.util.color as color_util
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
SUPPORT_YEELIGHT_SUNFLOWER = SUPPORT_BRIGHTNESS | SUPPORT_COLOR
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_HOST): cv.string})
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({vol.Required(CONF_HOST): cv.string})
|
||||||
|
|
||||||
|
|
||||||
@ -48,6 +45,9 @@ def setup_platform(
|
|||||||
class SunflowerBulb(LightEntity):
|
class SunflowerBulb(LightEntity):
|
||||||
"""Representation of a Yeelight Sunflower Light."""
|
"""Representation of a Yeelight Sunflower Light."""
|
||||||
|
|
||||||
|
_attr_color_mode = ColorMode.HS
|
||||||
|
_attr_supported_color_modes = {ColorMode.HS}
|
||||||
|
|
||||||
def __init__(self, light):
|
def __init__(self, light):
|
||||||
"""Initialize a Yeelight Sunflower bulb."""
|
"""Initialize a Yeelight Sunflower bulb."""
|
||||||
self._light = light
|
self._light = light
|
||||||
@ -87,11 +87,6 @@ class SunflowerBulb(LightEntity):
|
|||||||
"""Return the color property."""
|
"""Return the color property."""
|
||||||
return color_util.color_RGB_to_hs(*self._rgb_color)
|
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):
|
def turn_on(self, **kwargs):
|
||||||
"""Instruct the light to turn on, optionally set colour/brightness."""
|
"""Instruct the light to turn on, optionally set colour/brightness."""
|
||||||
# when no arguments, just turn light on (full brightness)
|
# when no arguments, just turn light on (full brightness)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user