mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Added support to 'effect: random' to Osram Lightify lights (#3192)
* Added support to 'effect: random' to Osram Lightify lights * removed extra line not required
This commit is contained in:
parent
892f6a706a
commit
7bab4055a5
@ -6,6 +6,7 @@ https://home-assistant.io/components/light.osramlightify/
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
|
import random
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant import util
|
from homeassistant import util
|
||||||
@ -14,9 +15,12 @@ from homeassistant.components.light import (
|
|||||||
Light,
|
Light,
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_COLOR_TEMP,
|
ATTR_COLOR_TEMP,
|
||||||
|
ATTR_EFFECT,
|
||||||
ATTR_RGB_COLOR,
|
ATTR_RGB_COLOR,
|
||||||
ATTR_TRANSITION,
|
ATTR_TRANSITION,
|
||||||
|
EFFECT_RANDOM,
|
||||||
SUPPORT_BRIGHTNESS,
|
SUPPORT_BRIGHTNESS,
|
||||||
|
SUPPORT_EFFECT,
|
||||||
SUPPORT_COLOR_TEMP,
|
SUPPORT_COLOR_TEMP,
|
||||||
SUPPORT_RGB_COLOR,
|
SUPPORT_RGB_COLOR,
|
||||||
SUPPORT_TRANSITION,
|
SUPPORT_TRANSITION,
|
||||||
@ -33,7 +37,8 @@ MIN_TIME_BETWEEN_SCANS = timedelta(seconds=10)
|
|||||||
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)
|
MIN_TIME_BETWEEN_FORCED_SCANS = timedelta(milliseconds=100)
|
||||||
|
|
||||||
SUPPORT_OSRAMLIGHTIFY = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP |
|
SUPPORT_OSRAMLIGHTIFY = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP |
|
||||||
SUPPORT_RGB_COLOR | SUPPORT_TRANSITION)
|
SUPPORT_EFFECT | SUPPORT_RGB_COLOR |
|
||||||
|
SUPPORT_TRANSITION)
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
@ -150,6 +155,13 @@ class OsramLightifyLight(Light):
|
|||||||
(TEMP_MAX_HASS - TEMP_MIN_HASS)) + TEMP_MIN)
|
(TEMP_MAX_HASS - TEMP_MIN_HASS)) + TEMP_MIN)
|
||||||
self._light.set_temperature(kelvin, fade)
|
self._light.set_temperature(kelvin, fade)
|
||||||
|
|
||||||
|
effect = kwargs.get(ATTR_EFFECT)
|
||||||
|
if effect == EFFECT_RANDOM:
|
||||||
|
self._light.set_rgb(random.randrange(0, 255),
|
||||||
|
random.randrange(0, 255),
|
||||||
|
random.randrange(0, 255),
|
||||||
|
fade)
|
||||||
|
|
||||||
self._light.set_luminance(brightness, fade)
|
self._light.set_luminance(brightness, fade)
|
||||||
self.update_ha_state()
|
self.update_ha_state()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user