mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Merge pull request #3051 from tchellomello/added_random_effect_flux_led
Added option to use effect:random for Flux Led light bulbs
This commit is contained in:
commit
16e0187fcc
@ -7,9 +7,11 @@ https://home-assistant.io/components/light.flux_led/
|
||||
|
||||
import logging
|
||||
import socket
|
||||
import random
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.light import (ATTR_BRIGHTNESS, ATTR_RGB_COLOR,
|
||||
ATTR_EFFECT, EFFECT_RANDOM,
|
||||
SUPPORT_BRIGHTNESS,
|
||||
SUPPORT_RGB_COLOR, Light)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
@ -125,10 +127,15 @@ class FluxLight(Light):
|
||||
|
||||
rgb = kwargs.get(ATTR_RGB_COLOR)
|
||||
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
||||
effect = kwargs.get(ATTR_EFFECT)
|
||||
if rgb:
|
||||
self._bulb.setRgb(*tuple(rgb))
|
||||
elif brightness:
|
||||
self._bulb.setWarmWhite255(brightness)
|
||||
elif effect == EFFECT_RANDOM:
|
||||
self._bulb.setRgb(random.randrange(0, 255),
|
||||
random.randrange(0, 255),
|
||||
random.randrange(0, 255))
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn the specified or all lights off."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user