Added option to use effect:random for Flux Led light bulbs
This commit is contained in:
parent
4e044361c3
commit
650ec1a337
1 changed files with 7 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue