Better handling for the lights blink animation for groups

This commit is contained in:
Fabio Manganiello 2019-01-20 00:42:07 +01:00
parent d1b9fef740
commit 1f4efbb427

View file

@ -617,6 +617,13 @@ class LightHuePlugin(LightPlugin):
:type treansition_seconds: float :type treansition_seconds: float
""" """
if groups:
groups = [g for g in self.bridge.groups if g.name in groups]
lights = lights or []
for g in groups:
lights.extend([l.name for l in g.lights])
elif not lights:
lights = self.lights
def _initialize_light_attrs(lights): def _initialize_light_attrs(lights):
if animation == self.Animation.COLOR_TRANSITION: if animation == self.Animation.COLOR_TRANSITION:
@ -693,7 +700,7 @@ class LightHuePlugin(LightPlugin):
self.logger.debug('Setting lights to {}'.format(conf)) self.logger.debug('Setting lights to {}'.format(conf))
if groups: if groups:
self.bridge.set_group([g.name for f in groups], conf) self.bridge.set_group([g.name for g in groups], conf)
else: else:
self.bridge.set_light(lights.keys(), conf) self.bridge.set_light(lights.keys(), conf)
@ -709,14 +716,6 @@ class LightHuePlugin(LightPlugin):
self.animation_thread = None self.animation_thread = None
self.redis = None self.redis = None
if groups:
groups = [g for g in self.bridge.groups if g.name in groups]
lights = lights or []
for g in groups:
lights.extend([l.name for l in g.lights])
elif not lights:
lights = self.lights
self.stop_animation() self.stop_animation()
self.animation_thread = Thread(target=_animate_thread, self.animation_thread = Thread(target=_animate_thread,
name='HueAnimate', name='HueAnimate',