mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Support xy_color with LIFX lights (#7208)
This commit is contained in:
parent
5c737cfa6e
commit
2d57c6a1c7
@ -16,9 +16,9 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
Light, PLATFORM_SCHEMA, ATTR_BRIGHTNESS, ATTR_COLOR_NAME, ATTR_RGB_COLOR,
|
Light, PLATFORM_SCHEMA, ATTR_BRIGHTNESS, ATTR_COLOR_NAME, ATTR_RGB_COLOR,
|
||||||
ATTR_COLOR_TEMP, ATTR_TRANSITION, ATTR_EFFECT,
|
ATTR_XY_COLOR, ATTR_COLOR_TEMP, ATTR_TRANSITION, ATTR_EFFECT,
|
||||||
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR,
|
SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_RGB_COLOR,
|
||||||
SUPPORT_TRANSITION, SUPPORT_EFFECT)
|
SUPPORT_XY_COLOR, SUPPORT_TRANSITION, SUPPORT_EFFECT)
|
||||||
from homeassistant.util.color import (
|
from homeassistant.util.color import (
|
||||||
color_temperature_mired_to_kelvin, color_temperature_kelvin_to_mired)
|
color_temperature_mired_to_kelvin, color_temperature_kelvin_to_mired)
|
||||||
from homeassistant import util
|
from homeassistant import util
|
||||||
@ -46,7 +46,7 @@ BYTE_MAX = 255
|
|||||||
SHORT_MAX = 65535
|
SHORT_MAX = 65535
|
||||||
|
|
||||||
SUPPORT_LIFX = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR |
|
SUPPORT_LIFX = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_RGB_COLOR |
|
||||||
SUPPORT_TRANSITION | SUPPORT_EFFECT)
|
SUPPORT_XY_COLOR | SUPPORT_TRANSITION | SUPPORT_EFFECT)
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_SERVER, default='0.0.0.0'): cv.string,
|
vol.Optional(CONF_SERVER, default='0.0.0.0'): cv.string,
|
||||||
@ -358,6 +358,14 @@ class LIFXLight(Light):
|
|||||||
else:
|
else:
|
||||||
brightness = self._bri
|
brightness = self._bri
|
||||||
|
|
||||||
|
if ATTR_XY_COLOR in kwargs:
|
||||||
|
hue, saturation, _ = \
|
||||||
|
color_util.color_xy_brightness_to_hsv(
|
||||||
|
*kwargs[ATTR_XY_COLOR],
|
||||||
|
ibrightness=(brightness // (BYTE_MAX + 1)))
|
||||||
|
saturation = saturation * (BYTE_MAX + 1)
|
||||||
|
changed_color = True
|
||||||
|
|
||||||
if ATTR_COLOR_TEMP in kwargs:
|
if ATTR_COLOR_TEMP in kwargs:
|
||||||
kelvin = int(color_temperature_mired_to_kelvin(
|
kelvin = int(color_temperature_mired_to_kelvin(
|
||||||
kwargs[ATTR_COLOR_TEMP]))
|
kwargs[ATTR_COLOR_TEMP]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user