Skip to content

Commit

Permalink
Support xy_color with LIFX lights (#7208)
Browse files Browse the repository at this point in the history
  • Loading branch information
amelchio authored and balloob committed Apr 22, 2017
1 parent f5dd25c commit 2657668
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions homeassistant/components/light/lifx/__init__.py
Expand Up @@ -16,9 +16,9 @@

from homeassistant.components.light import (
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_TRANSITION, SUPPORT_EFFECT)
SUPPORT_XY_COLOR, SUPPORT_TRANSITION, SUPPORT_EFFECT)
from homeassistant.util.color import (
color_temperature_mired_to_kelvin, color_temperature_kelvin_to_mired)
from homeassistant import util
Expand Down Expand Up @@ -46,7 +46,7 @@
SHORT_MAX = 65535

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({
vol.Optional(CONF_SERVER, default='0.0.0.0'): cv.string,
Expand Down Expand Up @@ -358,6 +358,14 @@ def find_hsbk(self, **kwargs):
else:
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:
kelvin = int(color_temperature_mired_to_kelvin(
kwargs[ATTR_COLOR_TEMP]))
Expand Down

0 comments on commit 2657668

Please sign in to comment.