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
|
@ -7,12 +7,12 @@ https://home-assistant.io/components/light.deconz/
|
|||
from homeassistant.components.deconz import (
|
||||
DOMAIN as DATA_DECONZ, DATA_DECONZ_ID)
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_FLASH, ATTR_RGB_COLOR,
|
||||
ATTR_TRANSITION, ATTR_XY_COLOR, EFFECT_COLORLOOP, FLASH_LONG, FLASH_SHORT,
|
||||
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_EFFECT, SUPPORT_FLASH,
|
||||
SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, SUPPORT_XY_COLOR, Light)
|
||||
ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_FLASH, ATTR_HS_COLOR,
|
||||
ATTR_TRANSITION, EFFECT_COLORLOOP, FLASH_LONG, FLASH_SHORT,
|
||||
SUPPORT_BRIGHTNESS, SUPPORT_COLOR, SUPPORT_COLOR_TEMP, SUPPORT_EFFECT,
|
||||
SUPPORT_FLASH, SUPPORT_TRANSITION, Light)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.util.color import color_RGB_to_xy
|
||||
import homeassistant.util.color as color_util
|
||||
|
||||
DEPENDENCIES = ['deconz']
|
||||
|
||||
|
@ -51,8 +51,7 @@ class DeconzLight(Light):
|
|||
self._features |= SUPPORT_COLOR_TEMP
|
||||
|
||||
if self._light.xy is not None:
|
||||
self._features |= SUPPORT_RGB_COLOR
|
||||
self._features |= SUPPORT_XY_COLOR
|
||||
self._features |= SUPPORT_COLOR
|
||||
|
||||
if self._light.effect is not None:
|
||||
self._features |= SUPPORT_EFFECT
|
||||
|
@ -124,14 +123,8 @@ class DeconzLight(Light):
|
|||
if ATTR_COLOR_TEMP in kwargs:
|
||||
data['ct'] = kwargs[ATTR_COLOR_TEMP]
|
||||
|
||||
if ATTR_RGB_COLOR in kwargs:
|
||||
xyb = color_RGB_to_xy(
|
||||
*(int(val) for val in kwargs[ATTR_RGB_COLOR]))
|
||||
data['xy'] = xyb[0], xyb[1]
|
||||
data['bri'] = xyb[2]
|
||||
|
||||
if ATTR_XY_COLOR in kwargs:
|
||||
data['xy'] = kwargs[ATTR_XY_COLOR]
|
||||
if ATTR_HS_COLOR in kwargs:
|
||||
data['xy'] = color_util.color_hs_to_xy(*kwargs[ATTR_HS_COLOR])
|
||||
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
data['bri'] = kwargs[ATTR_BRIGHTNESS]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue