mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
Whitelist yeelight predefined effects per device type (#24544)
* Whitelist yeelight predefined effects per device type * Fix support color
This commit is contained in:
parent
1e248551d5
commit
08eca4a237
@ -28,15 +28,14 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
SUPPORT_YEELIGHT = (SUPPORT_BRIGHTNESS |
|
SUPPORT_YEELIGHT = (SUPPORT_BRIGHTNESS |
|
||||||
SUPPORT_TRANSITION |
|
SUPPORT_TRANSITION |
|
||||||
SUPPORT_FLASH)
|
SUPPORT_FLASH |
|
||||||
|
SUPPORT_EFFECT)
|
||||||
|
|
||||||
SUPPORT_YEELIGHT_WHITE_TEMP = (SUPPORT_YEELIGHT |
|
SUPPORT_YEELIGHT_WHITE_TEMP = (SUPPORT_YEELIGHT |
|
||||||
SUPPORT_COLOR_TEMP)
|
SUPPORT_COLOR_TEMP)
|
||||||
|
|
||||||
SUPPORT_YEELIGHT_RGB = (SUPPORT_YEELIGHT |
|
SUPPORT_YEELIGHT_RGB = (SUPPORT_YEELIGHT_WHITE_TEMP |
|
||||||
SUPPORT_COLOR |
|
SUPPORT_COLOR)
|
||||||
SUPPORT_EFFECT |
|
|
||||||
SUPPORT_COLOR_TEMP)
|
|
||||||
|
|
||||||
ATTR_MODE = 'mode'
|
ATTR_MODE = 'mode'
|
||||||
|
|
||||||
@ -61,24 +60,33 @@ EFFECT_FACEBOOK = "Facebook"
|
|||||||
EFFECT_TWITTER = "Twitter"
|
EFFECT_TWITTER = "Twitter"
|
||||||
EFFECT_STOP = "Stop"
|
EFFECT_STOP = "Stop"
|
||||||
|
|
||||||
YEELIGHT_EFFECT_LIST = [
|
YEELIGHT_TEMP_ONLY_EFFECT_LIST = [
|
||||||
EFFECT_DISCO,
|
|
||||||
EFFECT_TEMP,
|
EFFECT_TEMP,
|
||||||
|
EFFECT_STOP,
|
||||||
|
]
|
||||||
|
|
||||||
|
YEELIGHT_MONO_EFFECT_LIST = [
|
||||||
|
EFFECT_DISCO,
|
||||||
EFFECT_STROBE,
|
EFFECT_STROBE,
|
||||||
EFFECT_STROBE_COLOR,
|
|
||||||
EFFECT_ALARM,
|
EFFECT_ALARM,
|
||||||
EFFECT_POLICE,
|
|
||||||
EFFECT_POLICE2,
|
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_CHRISTMAS,
|
||||||
EFFECT_RGB,
|
EFFECT_RGB,
|
||||||
EFFECT_RANDOM_LOOP,
|
EFFECT_RANDOM_LOOP,
|
||||||
EFFECT_FAST_RANDOM_LOOP,
|
EFFECT_FAST_RANDOM_LOOP,
|
||||||
EFFECT_LSD,
|
EFFECT_LSD,
|
||||||
EFFECT_SLOWDOWN,
|
EFFECT_SLOWDOWN,
|
||||||
EFFECT_WHATSAPP,
|
*YEELIGHT_MONO_EFFECT_LIST
|
||||||
EFFECT_FACEBOOK,
|
]
|
||||||
EFFECT_TWITTER,
|
|
||||||
EFFECT_STOP]
|
|
||||||
|
|
||||||
MODEL_TO_DEVICE_TYPE = {
|
MODEL_TO_DEVICE_TYPE = {
|
||||||
'mono': BulbType.White,
|
'mono': BulbType.White,
|
||||||
@ -262,7 +270,7 @@ class YeelightGenericLight(Light):
|
|||||||
@property
|
@property
|
||||||
def effect_list(self):
|
def effect_list(self):
|
||||||
"""Return the list of supported effects."""
|
"""Return the list of supported effects."""
|
||||||
return YEELIGHT_EFFECT_LIST + self.custom_effects_names
|
return self._predefined_effects + self.custom_effects_names
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def color_temp(self) -> int:
|
def color_temp(self) -> int:
|
||||||
@ -342,6 +350,10 @@ class YeelightGenericLight(Light):
|
|||||||
def _power_property(self):
|
def _power_property(self):
|
||||||
return 'power'
|
return 'power'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _predefined_effects(self):
|
||||||
|
return YEELIGHT_MONO_EFFECT_LIST
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device(self):
|
def device(self):
|
||||||
"""Return yeelight device."""
|
"""Return yeelight device."""
|
||||||
@ -575,6 +587,10 @@ class YeelightColorLight(YeelightGenericLight):
|
|||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return SUPPORT_YEELIGHT_RGB
|
return SUPPORT_YEELIGHT_RGB
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _predefined_effects(self):
|
||||||
|
return YEELIGHT_COLOR_EFFECT_LIST
|
||||||
|
|
||||||
|
|
||||||
class YeelightWhiteTempLight(YeelightGenericLight):
|
class YeelightWhiteTempLight(YeelightGenericLight):
|
||||||
"""Representation of a Color Yeelight light."""
|
"""Representation of a Color Yeelight light."""
|
||||||
@ -588,6 +604,10 @@ class YeelightWhiteTempLight(YeelightGenericLight):
|
|||||||
def _brightness_property(self):
|
def _brightness_property(self):
|
||||||
return 'current_brightness'
|
return 'current_brightness'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _predefined_effects(self):
|
||||||
|
return YEELIGHT_TEMP_ONLY_EFFECT_LIST
|
||||||
|
|
||||||
|
|
||||||
class YeelightWithAmbientLight(YeelightWhiteTempLight):
|
class YeelightWithAmbientLight(YeelightWhiteTempLight):
|
||||||
"""Representation of a Yeelight which has ambilight support."""
|
"""Representation of a Yeelight which has ambilight support."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user