From 86b34b40a14a5817ec2eb60ad30f7213a1cb951c Mon Sep 17 00:00:00 2001 From: Anders Melchiorsen Date: Mon, 8 May 2017 16:51:27 +0200 Subject: [PATCH] LIFX: avoid out-of-bounds hue aborting the colorloop effect (#7495) The hue is now a float but the hsbk conversion still believed it to be an integer that could not be larger than 359. The float can in fact be, for example, 359.9 and this would cause an out-of-bounds error in the set_color call. For completeness, the initial hue is also changed to a float. --- homeassistant/components/light/lifx/effects.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/light/lifx/effects.py b/homeassistant/components/light/lifx/effects.py index a15360df33..85de663a81 100644 --- a/homeassistant/components/light/lifx/effects.py +++ b/homeassistant/components/light/lifx/effects.py @@ -292,7 +292,7 @@ class LIFXEffectColorloop(LIFXEffect): direction = 1 if random.randint(0, 1) else -1 # Random start - hue = random.randint(0, 359) + hue = random.uniform(0, 360) % 360 while self.lights: hue = (hue + direction*change) % 360 @@ -312,7 +312,7 @@ class LIFXEffectColorloop(LIFXEffect): brightness = light.effect_data.color[2] hsbk = [ - int(65535/359*lhue), + int(65535/360*lhue), int(random.uniform(0.8, 1.0)*65535), brightness, NEUTRAL_WHITE,