Demo component now supports brightness/color for lights
This commit is contained in:
parent
4dcaf12fa7
commit
d506d0f424
1 changed files with 14 additions and 4 deletions
|
@ -13,8 +13,8 @@ from homeassistant.const import (
|
|||
SERVICE_TURN_ON, SERVICE_TURN_OFF, STATE_ON, STATE_OFF,
|
||||
ATTR_ENTITY_PICTURE, ATTR_ENTITY_ID, CONF_LATITUDE, CONF_LONGITUDE)
|
||||
from homeassistant.components.light import (
|
||||
ATTR_XY_COLOR, ATTR_BRIGHTNESS, GROUP_NAME_ALL_LIGHTS)
|
||||
from homeassistant.util import split_entity_id
|
||||
ATTR_XY_COLOR, ATTR_RGB_COLOR, ATTR_BRIGHTNESS, GROUP_NAME_ALL_LIGHTS)
|
||||
from homeassistant.util import split_entity_id, color_RGB_to_xy
|
||||
|
||||
DOMAIN = "demo"
|
||||
|
||||
|
@ -48,8 +48,18 @@ def setup(hass, config):
|
|||
domain, _ = split_entity_id(entity_id)
|
||||
|
||||
if domain == "light":
|
||||
data = {ATTR_BRIGHTNESS: 200,
|
||||
ATTR_XY_COLOR: random.choice(light_colors)}
|
||||
rgb_color = service.data.get(ATTR_RGB_COLOR)
|
||||
|
||||
if rgb_color is None:
|
||||
color = random.choice(light_colors)
|
||||
else:
|
||||
color = color_RGB_to_xy(
|
||||
rgb_color[0], rgb_color[1], rgb_color[2])
|
||||
|
||||
data = {
|
||||
ATTR_BRIGHTNESS: service.data.get(ATTR_BRIGHTNESS, 200),
|
||||
ATTR_XY_COLOR: color
|
||||
}
|
||||
else:
|
||||
data = None
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue