From 1aa3ab52b7430d1b9695c9aa17d6ecec28211805 Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Wed, 3 May 2017 00:41:43 +0200 Subject: [PATCH] LIFX: Add transition option to colorloop effect (#7410) This allows for more of a disco mode where lights change so fast that you actually notice it. Also change the valid period to the maximum 20 msgs/sec that LIFX bulbs can handle. --- homeassistant/components/light/lifx/effects.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/light/lifx/effects.py b/homeassistant/components/light/lifx/effects.py index 7904529bda3..07b97d03a12 100644 --- a/homeassistant/components/light/lifx/effects.py +++ b/homeassistant/components/light/lifx/effects.py @@ -7,7 +7,8 @@ from os import path import voluptuous as vol from homeassistant.components.light import ( - DOMAIN, ATTR_BRIGHTNESS, ATTR_COLOR_NAME, ATTR_RGB_COLOR, ATTR_EFFECT) + DOMAIN, ATTR_BRIGHTNESS, ATTR_COLOR_NAME, ATTR_RGB_COLOR, ATTR_EFFECT, + ATTR_TRANSITION) from homeassistant.config import load_yaml_config_file from homeassistant.const import (ATTR_ENTITY_ID) from homeassistant.helpers.service import extract_entity_ids @@ -51,11 +52,12 @@ LIFX_EFFECT_PULSE_SCHEMA = LIFX_EFFECT_BREATHE_SCHEMA LIFX_EFFECT_COLORLOOP_SCHEMA = LIFX_EFFECT_SCHEMA.extend({ ATTR_BRIGHTNESS: vol.All(vol.Coerce(int), vol.Clamp(min=0, max=255)), vol.Optional(ATTR_PERIOD, default=60): - vol.All(vol.Coerce(float), vol.Clamp(min=1)), + vol.All(vol.Coerce(float), vol.Clamp(min=0.05)), vol.Optional(ATTR_CHANGE, default=20): vol.All(vol.Coerce(float), vol.Clamp(min=0, max=360)), vol.Optional(ATTR_SPREAD, default=30): vol.All(vol.Coerce(float), vol.Clamp(min=0, max=360)), + ATTR_TRANSITION: vol.All(vol.Coerce(float), vol.Range(min=0)), }) LIFX_EFFECT_STOP_SCHEMA = vol.Schema({ @@ -295,9 +297,10 @@ class LIFXEffectColorloop(LIFXEffect): random.shuffle(self.lights) lhue = hue - transition = int(1000 * random.uniform(period/2, period)) for light in self.lights: - if spread > 0: + if ATTR_TRANSITION in kwargs: + transition = int(1000*kwargs[ATTR_TRANSITION]) + elif light == self.lights[0] or spread > 0: transition = int(1000 * random.uniform(period/2, period)) if ATTR_BRIGHTNESS in kwargs: