Use hue/sat as internal light color interface (#11288)
* Accept and report both xy and RGB color for lights * Fix demo light supported_features * Add new XY color util functions * Always make color changes available as xy and RGB * Always expose color as RGB and XY * Consolidate color supported_features * Test fixes * Additional test fix * Use hue/sat as the hass core color interface * Tests updates * Assume MQTT RGB devices need full RGB brightness * Convert new platforms * More migration * Use float for HS API * Fix backwards conversion for KNX lights * Adjust limitless min saturation for new scale
This commit is contained in:
parent
6b059489a6
commit
89c7c80e42
57 changed files with 898 additions and 965 deletions
|
@ -10,15 +10,16 @@ import voluptuous as vol
|
|||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, ATTR_RGB_COLOR, SUPPORT_RGB_COLOR,
|
||||
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, ATTR_HS_COLOR, SUPPORT_COLOR,
|
||||
Light, PLATFORM_SCHEMA)
|
||||
from homeassistant.const import CONF_NAME
|
||||
import homeassistant.util.color as color_util
|
||||
|
||||
REQUIREMENTS = ['blinkt==0.1.0']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SUPPORT_BLINKT = (SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR)
|
||||
SUPPORT_BLINKT = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR)
|
||||
|
||||
DEFAULT_NAME = 'blinkt'
|
||||
|
||||
|
@ -55,7 +56,7 @@ class BlinktLight(Light):
|
|||
self._index = index
|
||||
self._is_on = False
|
||||
self._brightness = 255
|
||||
self._rgb_color = [255, 255, 255]
|
||||
self._hs_color = [0, 0]
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@ -71,12 +72,9 @@ class BlinktLight(Light):
|
|||
return self._brightness
|
||||
|
||||
@property
|
||||
def rgb_color(self):
|
||||
"""Read back the color of the light.
|
||||
|
||||
Returns [r, g, b] list with values in range of 0-255.
|
||||
"""
|
||||
return self._rgb_color
|
||||
def hs_color(self):
|
||||
"""Read back the color of the light."""
|
||||
return self._hs_color
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
|
@ -100,16 +98,17 @@ class BlinktLight(Light):
|
|||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Instruct the light to turn on and set correct brightness & color."""
|
||||
if ATTR_RGB_COLOR in kwargs:
|
||||
self._rgb_color = kwargs[ATTR_RGB_COLOR]
|
||||
if ATTR_HS_COLOR in kwargs:
|
||||
self._hs_color = kwargs[ATTR_HS_COLOR]
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
self._brightness = kwargs[ATTR_BRIGHTNESS]
|
||||
|
||||
percent_bright = (self._brightness / 255)
|
||||
rgb_color = color_util.color_hs_to_RGB(*self._hs_color)
|
||||
self._blinkt.set_pixel(self._index,
|
||||
self._rgb_color[0],
|
||||
self._rgb_color[1],
|
||||
self._rgb_color[2],
|
||||
rgb_color[0],
|
||||
rgb_color[1],
|
||||
rgb_color[2],
|
||||
percent_bright)
|
||||
|
||||
self._blinkt.show()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue