From e4d33bc6d4f5e9a0e16cdba5ac0526178275b977 Mon Sep 17 00:00:00 2001 From: Tom Duijf Date: Tue, 27 Oct 2015 22:45:35 +0000 Subject: [PATCH] Included ct_color in code coverage --- homeassistant/components/light/demo.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/light/demo.py b/homeassistant/components/light/demo.py index 40a8cc023c5..0d72ef0dafd 100644 --- a/homeassistant/components/light/demo.py +++ b/homeassistant/components/light/demo.py @@ -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]