mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +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)
|
||||
white = kwargs.get(ATTR_WHITE_VALUE)
|
||||
|
||||
# color change only
|
||||
if rgb is not None:
|
||||
self._bulb.setRgb(*tuple(rgb), brightness=self.brightness)
|
||||
# Show warning if effect set with rgb, brightness, or white level
|
||||
if effect and (brightness or white or rgb):
|
||||
_LOGGER.warning("RGB, brightness and white level are ignored when"
|
||||
" an effect is specified for a flux bulb")
|
||||
|
||||
# brightness change only
|
||||
elif brightness is not None:
|
||||
(red, green, blue) = self._bulb.getRgb()
|
||||
self._bulb.setRgb(red, green, blue, brightness=brightness)
|
||||
|
||||
# random color effect
|
||||
elif effect == EFFECT_RANDOM:
|
||||
# Random color effect
|
||||
if effect == EFFECT_RANDOM:
|
||||
self._bulb.setRgb(random.randint(0, 255),
|
||||
random.randint(0, 255),
|
||||
random.randint(0, 255))
|
||||
return
|
||||
|
||||
# effect selection
|
||||
# Effect selection
|
||||
elif effect in EFFECT_MAP:
|
||||
self._bulb.setPresetPattern(EFFECT_MAP[effect], 50)
|
||||
return
|
||||
|
||||
# white change only
|
||||
elif white is not None:
|
||||
# Preserve current brightness on color/white level change
|
||||
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)
|
||||
|
||||
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,
|
||||
xy_color=[x_val, y_val],
|
||||
brightness=brightness,
|
||||
transition=transition)
|
||||
transition=transition,
|
||||
white_value=brightness)
|
||||
|
||||
|
||||
def set_lights_temp(hass, lights, mired, brightness, transition):
|
||||
|
Loading…
x
Reference in New Issue
Block a user