Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 33 additions & 13 deletions homeassistant/components/yeelight/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@

SUPPORT_YEELIGHT = (SUPPORT_BRIGHTNESS |
SUPPORT_TRANSITION |
SUPPORT_FLASH)
SUPPORT_FLASH |
SUPPORT_EFFECT)

SUPPORT_YEELIGHT_WHITE_TEMP = (SUPPORT_YEELIGHT |
SUPPORT_COLOR_TEMP)

SUPPORT_YEELIGHT_RGB = (SUPPORT_YEELIGHT |
SUPPORT_COLOR |
SUPPORT_EFFECT |
SUPPORT_YEELIGHT_RGB = (SUPPORT_YEELIGHT_WHITE_TEMP |
SUPPORT_COLOR_TEMP)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed SUPPORT_COLOR, not SUPPORT_COLOR_TEMP.


ATTR_MODE = 'mode'
Expand All @@ -61,24 +60,33 @@
EFFECT_TWITTER = "Twitter"
EFFECT_STOP = "Stop"

YEELIGHT_EFFECT_LIST = [
EFFECT_DISCO,
YEELIGHT_TEMP_ONLY_EFFECT_LIST = [
EFFECT_TEMP,
EFFECT_STOP,
]

YEELIGHT_MONO_EFFECT_LIST = [
EFFECT_DISCO,
EFFECT_STROBE,
EFFECT_STROBE_COLOR,
EFFECT_ALARM,
EFFECT_POLICE,
EFFECT_POLICE2,
EFFECT_WHATSAPP,
EFFECT_FACEBOOK,
EFFECT_TWITTER,
*YEELIGHT_TEMP_ONLY_EFFECT_LIST
]

YEELIGHT_COLOR_EFFECT_LIST = [
EFFECT_STROBE_COLOR,
EFFECT_POLICE,
EFFECT_CHRISTMAS,
EFFECT_RGB,
EFFECT_RANDOM_LOOP,
EFFECT_FAST_RANDOM_LOOP,
EFFECT_LSD,
EFFECT_SLOWDOWN,
EFFECT_WHATSAPP,
EFFECT_FACEBOOK,
EFFECT_TWITTER,
EFFECT_STOP]
*YEELIGHT_MONO_EFFECT_LIST
]

MODEL_TO_DEVICE_TYPE = {
'mono': BulbType.White,
Expand Down Expand Up @@ -262,7 +270,7 @@ def supported_features(self) -> int:
@property
def effect_list(self):
"""Return the list of supported effects."""
return YEELIGHT_EFFECT_LIST + self.custom_effects_names
return self._predefined_effects + self.custom_effects_names

@property
def color_temp(self) -> int:
Expand Down Expand Up @@ -342,6 +350,10 @@ def _brightness_property(self):
def _power_property(self):
return 'power'

@property
def _predefined_effects(self):
return YEELIGHT_MONO_EFFECT_LIST

@property
def device(self):
"""Return yeelight device."""
Expand Down Expand Up @@ -575,6 +587,10 @@ def supported_features(self) -> int:
"""Flag supported features."""
return SUPPORT_YEELIGHT_RGB

@property
def _predefined_effects(self):
return YEELIGHT_COLOR_EFFECT_LIST


class YeelightWhiteTempLight(YeelightGenericLight):
"""Representation of a Color Yeelight light."""
Expand All @@ -588,6 +604,10 @@ def supported_features(self) -> int:
def _brightness_property(self):
return 'current_brightness'

@property
def _predefined_effects(self):
return YEELIGHT_TEMP_ONLY_EFFECT_LIST


class YeelightWithAmbientLight(YeelightWhiteTempLight):
"""Representation of a Yeelight which has ambilight support."""
Expand Down