mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Included ct_color in code coverage
This commit is contained in:
parent
e25503bc4a
commit
e4d33bc6d4
@ -8,7 +8,7 @@ Demo platform that implements lights.
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
Light, ATTR_BRIGHTNESS, ATTR_XY_COLOR)
|
Light, ATTR_BRIGHTNESS, ATTR_XY_COLOR, ATTR_CT_COLOR)
|
||||||
|
|
||||||
|
|
||||||
LIGHT_COLORS = [
|
LIGHT_COLORS = [
|
||||||
@ -16,22 +16,25 @@ LIGHT_COLORS = [
|
|||||||
[0.460, 0.470],
|
[0.460, 0.470],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
LIGHT_TEMPS = [160, 300, 500]
|
||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
""" Find and return demo lights. """
|
""" Find and return demo lights. """
|
||||||
add_devices_callback([
|
add_devices_callback([
|
||||||
DemoLight("Bed Light", False),
|
DemoLight("Bed Light", False),
|
||||||
DemoLight("Ceiling Lights", True, LIGHT_COLORS[0]),
|
DemoLight("Ceiling Lights", True, LIGHT_TEMPS[1], LIGHT_COLORS[0]),
|
||||||
DemoLight("Kitchen Lights", True, LIGHT_COLORS[1])
|
DemoLight("Kitchen Lights", True, LIGHT_TEMPS[0], LIGHT_COLORS[1])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
class DemoLight(Light):
|
class DemoLight(Light):
|
||||||
""" Provides a demo switch. """
|
""" 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._name = name
|
||||||
self._state = state
|
self._state = state
|
||||||
self._xy = xy or random.choice(LIGHT_COLORS)
|
self._xy = xy or random.choice(LIGHT_COLORS)
|
||||||
|
self._ct = ct or random.choice(LIGHT_TEMPS)
|
||||||
self._brightness = brightness
|
self._brightness = brightness
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -54,6 +57,11 @@ class DemoLight(Light):
|
|||||||
""" XY color value. """
|
""" XY color value. """
|
||||||
return self._xy
|
return self._xy
|
||||||
|
|
||||||
|
@property
|
||||||
|
def color_ct(self):
|
||||||
|
""" CT color temperature. """
|
||||||
|
return self._ct
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
""" True if device is on. """
|
""" True if device is on. """
|
||||||
@ -66,6 +74,9 @@ class DemoLight(Light):
|
|||||||
if ATTR_XY_COLOR in kwargs:
|
if ATTR_XY_COLOR in kwargs:
|
||||||
self._xy = kwargs[ATTR_XY_COLOR]
|
self._xy = kwargs[ATTR_XY_COLOR]
|
||||||
|
|
||||||
|
if ATTR_CT_COLOR in kwargs:
|
||||||
|
self._ct = kwargs[ATTR_CT_COLOR]
|
||||||
|
|
||||||
if ATTR_BRIGHTNESS in kwargs:
|
if ATTR_BRIGHTNESS in kwargs:
|
||||||
self._brightness = kwargs[ATTR_BRIGHTNESS]
|
self._brightness = kwargs[ATTR_BRIGHTNESS]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user