From d94db5388c42c70bb9e404fcf3595da839b80af7 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 25 Jan 2016 03:32:55 +0000 Subject: [PATCH] Add preliminary support for transition time --- homeassistant/components/light/lifx.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/light/lifx.py b/homeassistant/components/light/lifx.py index afe2196b0e0..8ff99403e05 100644 --- a/homeassistant/components/light/lifx.py +++ b/homeassistant/components/light/lifx.py @@ -24,7 +24,7 @@ import logging import colorsys from homeassistant.helpers.event import track_time_change from homeassistant.components.light import \ - (Light, ATTR_BRIGHTNESS, ATTR_RGB_COLOR, ATTR_COLOR_TEMP) + (Light, ATTR_BRIGHTNESS, ATTR_RGB_COLOR, ATTR_COLOR_TEMP, ATTR_TRANSITION) _LOGGER = logging.getLogger(__name__) @@ -172,6 +172,11 @@ class LIFXLight(Light): def turn_on(self, **kwargs): """ Turn the device on. """ + if ATTR_TRANSITION in kwargs: + fade = kwargs[ATTR_TRANSITION] * 1000 + else: + fade = 0 + if ATTR_BRIGHTNESS in kwargs: brightness = kwargs[ATTR_BRIGHTNESS] * (BYTE_MAX + 1) else: @@ -192,15 +197,21 @@ class LIFXLight(Light): else: kelvin = self._kel + _LOGGER.info("%s %d %d %d %d %d", self._ip, hue, saturation, brightness, kelvin, fade) if self._power == 0: - self._liffylights.set_power(self._ip, 65535) + self._liffylights.set_power(self._ip, 65535, 0) self._liffylights.set_color(self._ip, hue, saturation, - brightness, kelvin) + brightness, kelvin, fade) def turn_off(self, **kwargs): """ Turn the device off. """ - self._liffylights.set_power(self._ip, 0) + if ATTR_TRANSITION in kwargs: + fade = kwargs[ATTR_TRANSITION] * 1000 + else: + fade = 0 + + self._liffylights.set_power(self._ip, 0, fade) def set_name(self, name): """ Set name. """