Included ct_color in code coverage

This commit is contained in:
Tom Duijf 2015-10-27 22:45:35 +00:00
parent e25503bc4a
commit e4d33bc6d4

View file

@ -8,7 +8,7 @@ Demo platform that implements lights.
import random
from homeassistant.components.light import (
Light, ATTR_BRIGHTNESS, ATTR_XY_COLOR)
Light, ATTR_BRIGHTNESS, ATTR_XY_COLOR, ATTR_CT_COLOR)
LIGHT_COLORS = [
@ -16,22 +16,25 @@ LIGHT_COLORS = [
[0.460, 0.470],
]
LIGHT_TEMPS = [160, 300, 500]
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
""" Find and return demo lights. """
add_devices_callback([
DemoLight("Bed Light", False),
DemoLight("Ceiling Lights", True, LIGHT_COLORS[0]),
DemoLight("Kitchen Lights", True, LIGHT_COLORS[1])
DemoLight("Ceiling Lights", True, LIGHT_TEMPS[1], LIGHT_COLORS[0]),
DemoLight("Kitchen Lights", True, LIGHT_TEMPS[0], LIGHT_COLORS[1])
])
class DemoLight(Light):
""" Provides a demo switch. """
def __init__(self, name, state, xy=None, brightness=180):
def __init__(self, name, state, xy=None, ct=None, brightness=180):
self._name = name
self._state = state
self._xy = xy or random.choice(LIGHT_COLORS)
self._ct = ct or random.choice(LIGHT_TEMPS)
self._brightness = brightness
@property
@ -54,6 +57,11 @@ class DemoLight(Light):
""" XY color value. """
return self._xy
@property
def color_ct(self):
""" CT color temperature. """
return self._ct
@property
def is_on(self):
""" True if device is on. """
@ -66,6 +74,9 @@ class DemoLight(Light):
if ATTR_XY_COLOR in kwargs:
self._xy = kwargs[ATTR_XY_COLOR]
if ATTR_CT_COLOR in kwargs:
self._ct = kwargs[ATTR_CT_COLOR]
if ATTR_BRIGHTNESS in kwargs:
self._brightness = kwargs[ATTR_BRIGHTNESS]