From 1f4efbb427ef0b1a9effd308e42b4a3d1ce647e0 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 20 Jan 2019 00:42:07 +0100 Subject: [PATCH] Better handling for the lights blink animation for groups --- platypush/plugins/light/hue/__init__.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/platypush/plugins/light/hue/__init__.py b/platypush/plugins/light/hue/__init__.py index ad18e4af1d..a17481a659 100644 --- a/platypush/plugins/light/hue/__init__.py +++ b/platypush/plugins/light/hue/__init__.py @@ -617,6 +617,13 @@ class LightHuePlugin(LightPlugin): :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): if animation == self.Animation.COLOR_TRANSITION: @@ -693,7 +700,7 @@ class LightHuePlugin(LightPlugin): self.logger.debug('Setting lights to {}'.format(conf)) 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: self.bridge.set_light(lights.keys(), conf) @@ -709,14 +716,6 @@ class LightHuePlugin(LightPlugin): self.animation_thread = 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.animation_thread = Thread(target=_animate_thread, name='HueAnimate',