mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 02:07:09 +00:00
Flux bug fix (#14476)
* Simplify conditionals. * Send white_value on service call. * Remove extra blank line * Further simplification of conditionals * Requested changes * Do not call getRgb if not needed * Update log message
This commit is contained in:
parent
97076aa3fd
commit
909f2448ca
@ -222,27 +222,34 @@ class FluxLight(Light):
|
|||||||
effect = kwargs.get(ATTR_EFFECT)
|
effect = kwargs.get(ATTR_EFFECT)
|
||||||
white = kwargs.get(ATTR_WHITE_VALUE)
|
white = kwargs.get(ATTR_WHITE_VALUE)
|
||||||
|
|
||||||
# color change only
|
# Show warning if effect set with rgb, brightness, or white level
|
||||||
if rgb is not None:
|
if effect and (brightness or white or rgb):
|
||||||
self._bulb.setRgb(*tuple(rgb), brightness=self.brightness)
|
_LOGGER.warning("RGB, brightness and white level are ignored when"
|
||||||
|
" an effect is specified for a flux bulb")
|
||||||
|
|
||||||
# brightness change only
|
# Random color effect
|
||||||
elif brightness is not None:
|
if effect == EFFECT_RANDOM:
|
||||||
(red, green, blue) = self._bulb.getRgb()
|
|
||||||
self._bulb.setRgb(red, green, blue, brightness=brightness)
|
|
||||||
|
|
||||||
# random color effect
|
|
||||||
elif effect == EFFECT_RANDOM:
|
|
||||||
self._bulb.setRgb(random.randint(0, 255),
|
self._bulb.setRgb(random.randint(0, 255),
|
||||||
random.randint(0, 255),
|
random.randint(0, 255),
|
||||||
random.randint(0, 255))
|
random.randint(0, 255))
|
||||||
|
return
|
||||||
|
|
||||||
# effect selection
|
# Effect selection
|
||||||
elif effect in EFFECT_MAP:
|
elif effect in EFFECT_MAP:
|
||||||
self._bulb.setPresetPattern(EFFECT_MAP[effect], 50)
|
self._bulb.setPresetPattern(EFFECT_MAP[effect], 50)
|
||||||
|
return
|
||||||
|
|
||||||
# white change only
|
# Preserve current brightness on color/white level change
|
||||||
elif white is not None:
|
if brightness is None:
|
||||||
|
brightness = self.brightness
|
||||||
|
|
||||||
|
# Preserve color on brightness/white level change
|
||||||
|
if rgb is None:
|
||||||
|
rgb = self._bulb.getRgb()
|
||||||
|
|
||||||
|
self._bulb.setRgb(*tuple(rgb), brightness=brightness)
|
||||||
|
|
||||||
|
if white is not None:
|
||||||
self._bulb.setWarmWhite255(white)
|
self._bulb.setWarmWhite255(white)
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
|
@ -72,7 +72,8 @@ def set_lights_xy(hass, lights, x_val, y_val, brightness, transition):
|
|||||||
turn_on(hass, light,
|
turn_on(hass, light,
|
||||||
xy_color=[x_val, y_val],
|
xy_color=[x_val, y_val],
|
||||||
brightness=brightness,
|
brightness=brightness,
|
||||||
transition=transition)
|
transition=transition,
|
||||||
|
white_value=brightness)
|
||||||
|
|
||||||
|
|
||||||
def set_lights_temp(hass, lights, mired, brightness, transition):
|
def set_lights_temp(hass, lights, mired, brightness, transition):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user