Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
33 changes: 20 additions & 13 deletions homeassistant/components/light/flux_led.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,27 +222,34 @@ def turn_on(self, **kwargs):
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

# 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)

# white change only
elif white is not None:
if white is not None:
self._bulb.setWarmWhite255(white)

def turn_off(self, **kwargs):
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/switch/flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down