From 3cd89f84745bd20ea170198268b0677beab1d4ac Mon Sep 17 00:00:00 2001 From: happyleaves Date: Sun, 1 Nov 2015 10:04:23 -0500 Subject: [PATCH 1/4] add disco, white effects --- homeassistant/components/light/__init__.py | 3 +++ .../components/light/limitlessled.py | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index 3bb2b1ab239..a7865e1f514 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -96,6 +96,7 @@ FLASH_LONG = "long" # Apply an effect to the light, can be EFFECT_COLORLOOP ATTR_EFFECT = "effect" EFFECT_COLORLOOP = "colorloop" +EFFECT_WHITE = "white" LIGHT_PROFILES_FILE = "light_profiles.csv" @@ -282,6 +283,8 @@ def setup(hass, config): if ATTR_EFFECT in dat: if dat[ATTR_EFFECT] == EFFECT_COLORLOOP: params[ATTR_EFFECT] = EFFECT_COLORLOOP + if dat[ATTR_EFFECT] == EFFECT_WHITE: + params[ATTR_EFFECT] = EFFECT_WHITE for light in target_lights: light.turn_on(**params) diff --git a/homeassistant/components/light/limitlessled.py b/homeassistant/components/light/limitlessled.py index b35ed379047..be9a59ede89 100644 --- a/homeassistant/components/light/limitlessled.py +++ b/homeassistant/components/light/limitlessled.py @@ -18,7 +18,8 @@ import logging from homeassistant.const import DEVICE_DEFAULT_NAME from homeassistant.components.light import (Light, ATTR_BRIGHTNESS, - ATTR_XY_COLOR) + ATTR_XY_COLOR, ATTR_EFFECT, + EFFECT_COLORLOOP, EFFECT_WHITE) from homeassistant.util.color import color_RGB_to_xy _LOGGER = logging.getLogger(__name__) @@ -159,10 +160,22 @@ class RGBWLimitlessLED(LimitlessLED): if ATTR_XY_COLOR in kwargs: self._xy_color = kwargs[ATTR_XY_COLOR] - self.pool.execute(self.controller_id, "set_color", - self._xy_to_led_color(self._xy_color), self.group) + effect = kwargs.get(ATTR_EFFECT) + + if effect: + if effect == EFFECT_COLORLOOP: + self.pool.execute(self.controller_id, "disco", self.group) + if effect == EFFECT_WHITE: + self.pool.execute(self.controller_id, "white", self.group) + else: + self.pool.execute(self.controller_id, "set_color", + self._xy_to_led_color(self._xy_color), + self.group) + + # Brightness can be set independently of color self.pool.execute(self.controller_id, "set_brightness", self._brightness / 255.0, self.group) + self.update_ha_state() From 566712023dac96ebb88d95b8a123822a3f82a09d Mon Sep 17 00:00:00 2001 From: happyleaves Date: Mon, 2 Nov 2015 17:24:24 -0500 Subject: [PATCH 2/4] consolidate conditionals --- homeassistant/components/light/limitlessled.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/light/limitlessled.py b/homeassistant/components/light/limitlessled.py index be9a59ede89..fef6cd0b8b1 100644 --- a/homeassistant/components/light/limitlessled.py +++ b/homeassistant/components/light/limitlessled.py @@ -162,11 +162,10 @@ class RGBWLimitlessLED(LimitlessLED): effect = kwargs.get(ATTR_EFFECT) - if effect: - if effect == EFFECT_COLORLOOP: - self.pool.execute(self.controller_id, "disco", self.group) - if effect == EFFECT_WHITE: - self.pool.execute(self.controller_id, "white", self.group) + if effect == EFFECT_COLORLOOP: + self.pool.execute(self.controller_id, "disco", self.group) + if effect == EFFECT_WHITE: + self.pool.execute(self.controller_id, "white", self.group) else: self.pool.execute(self.controller_id, "set_color", self._xy_to_led_color(self._xy_color), From 4d958c6d18e6016979b44cfe3ef72a6996c60100 Mon Sep 17 00:00:00 2001 From: happyleaves Date: Mon, 2 Nov 2015 17:51:17 -0500 Subject: [PATCH 3/4] style fix --- homeassistant/components/light/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index a7865e1f514..ab39474c093 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -157,7 +157,7 @@ def turn_off(hass, entity_id=None, transition=None): hass.services.call(DOMAIN, SERVICE_TURN_OFF, data) -# pylint: disable=too-many-branches, too-many-locals +# pylint: disable=too-many-branches, too-many-locals, too-many-statements def setup(hass, config): """ Exposes light control via statemachine and services. """ From 7b968f6a6b6b289a2d7f8b3823565d74341f7d09 Mon Sep 17 00:00:00 2001 From: happyleaves Date: Mon, 2 Nov 2015 18:11:58 -0500 Subject: [PATCH 4/4] re-fix conditionals --- homeassistant/components/light/limitlessled.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/light/limitlessled.py b/homeassistant/components/light/limitlessled.py index fef6cd0b8b1..0e2ce2230ac 100644 --- a/homeassistant/components/light/limitlessled.py +++ b/homeassistant/components/light/limitlessled.py @@ -164,7 +164,7 @@ class RGBWLimitlessLED(LimitlessLED): if effect == EFFECT_COLORLOOP: self.pool.execute(self.controller_id, "disco", self.group) - if effect == EFFECT_WHITE: + elif effect == EFFECT_WHITE: self.pool.execute(self.controller_id, "white", self.group) else: self.pool.execute(self.controller_id, "set_color",