mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Introduce SUPPORT_COLOR_TEMP for flux_led component (#26692)
* Introduce SUPPORT_COLOR_TEMP for flux_led component * Make black linter happy * Remove duplicate SUPPORT_COLOR_TEMP * Make linter happy
This commit is contained in:
parent
5c9f7484c2
commit
54361342ba
@ -12,12 +12,14 @@ from homeassistant.components.light import (
|
|||||||
ATTR_HS_COLOR,
|
ATTR_HS_COLOR,
|
||||||
ATTR_EFFECT,
|
ATTR_EFFECT,
|
||||||
ATTR_WHITE_VALUE,
|
ATTR_WHITE_VALUE,
|
||||||
|
ATTR_COLOR_TEMP,
|
||||||
EFFECT_COLORLOOP,
|
EFFECT_COLORLOOP,
|
||||||
EFFECT_RANDOM,
|
EFFECT_RANDOM,
|
||||||
SUPPORT_BRIGHTNESS,
|
SUPPORT_BRIGHTNESS,
|
||||||
SUPPORT_EFFECT,
|
SUPPORT_EFFECT,
|
||||||
SUPPORT_COLOR,
|
SUPPORT_COLOR,
|
||||||
SUPPORT_WHITE_VALUE,
|
SUPPORT_WHITE_VALUE,
|
||||||
|
SUPPORT_COLOR_TEMP,
|
||||||
Light,
|
Light,
|
||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
)
|
)
|
||||||
@ -43,6 +45,10 @@ MODE_RGBW = "rgbw"
|
|||||||
# RGB value is ignored when this mode is specified.
|
# RGB value is ignored when this mode is specified.
|
||||||
MODE_WHITE = "w"
|
MODE_WHITE = "w"
|
||||||
|
|
||||||
|
# Constant color temp values for 2 flux_led special modes
|
||||||
|
# Warm-white and Cool-white modes
|
||||||
|
COLOR_TEMP_WARM_VS_COLD_WHITE_CUT_OFF = 285
|
||||||
|
|
||||||
# List of supported effects which aren't already declared in LIGHT
|
# List of supported effects which aren't already declared in LIGHT
|
||||||
EFFECT_RED_FADE = "red_fade"
|
EFFECT_RED_FADE = "red_fade"
|
||||||
EFFECT_GREEN_FADE = "green_fade"
|
EFFECT_GREEN_FADE = "green_fade"
|
||||||
@ -235,7 +241,7 @@ class FluxLight(Light):
|
|||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
if self._mode == MODE_RGBW:
|
if self._mode == MODE_RGBW:
|
||||||
return SUPPORT_FLUX_LED | SUPPORT_WHITE_VALUE
|
return SUPPORT_FLUX_LED | SUPPORT_WHITE_VALUE | SUPPORT_COLOR_TEMP
|
||||||
|
|
||||||
if self._mode == MODE_WHITE:
|
if self._mode == MODE_WHITE:
|
||||||
return SUPPORT_BRIGHTNESS
|
return SUPPORT_BRIGHTNESS
|
||||||
@ -284,6 +290,17 @@ class FluxLight(Light):
|
|||||||
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
||||||
effect = kwargs.get(ATTR_EFFECT)
|
effect = kwargs.get(ATTR_EFFECT)
|
||||||
white = kwargs.get(ATTR_WHITE_VALUE)
|
white = kwargs.get(ATTR_WHITE_VALUE)
|
||||||
|
color_temp = kwargs.get(ATTR_COLOR_TEMP)
|
||||||
|
|
||||||
|
# handle special modes
|
||||||
|
if color_temp is not None:
|
||||||
|
if brightness is None:
|
||||||
|
brightness = self.brightness
|
||||||
|
if color_temp > COLOR_TEMP_WARM_VS_COLD_WHITE_CUT_OFF:
|
||||||
|
self._bulb.setRgbw(w=brightness)
|
||||||
|
else:
|
||||||
|
self._bulb.setRgbw(w2=brightness)
|
||||||
|
return
|
||||||
|
|
||||||
# Show warning if effect set with rgb, brightness, or white level
|
# Show warning if effect set with rgb, brightness, or white level
|
||||||
if effect and (brightness or white or rgb):
|
if effect and (brightness or white or rgb):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user