Always stop any running animation before resetting the lights to a static configuration
This commit is contained in:
parent
803aa68f11
commit
31a2aa67e2
1 changed files with 4 additions and 8 deletions
|
@ -97,6 +97,7 @@ class LightHuePlugin(LightPlugin):
|
||||||
def _exec(self, attr, *args, **kwargs):
|
def _exec(self, attr, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
self.connect()
|
self.connect()
|
||||||
|
self.stop_animation()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Reset bridge connection
|
# Reset bridge connection
|
||||||
self.bridge = None
|
self.bridge = None
|
||||||
|
@ -159,11 +160,8 @@ class LightHuePlugin(LightPlugin):
|
||||||
return self._exec('scene', name=name, lights=lights, groups=groups)
|
return self._exec('scene', name=name, lights=lights, groups=groups)
|
||||||
|
|
||||||
def stop_animation(self):
|
def stop_animation(self):
|
||||||
if not self.redis:
|
if self.animation_thread and self.animation_thread.is_alive():
|
||||||
self.logger.info('No animation is currently running')
|
self.redis.rpush(self.ANIMATION_CTRL_QUEUE_NAME, 'STOP')
|
||||||
return
|
|
||||||
|
|
||||||
self.redis.rpush(self.ANIMATION_CTRL_QUEUE_NAME, 'STOP')
|
|
||||||
|
|
||||||
def animate(self, animation, duration=None,
|
def animate(self, animation, duration=None,
|
||||||
hue_range=[0, MAX_HUE], sat_range=[0, MAX_SAT],
|
hue_range=[0, MAX_HUE], sat_range=[0, MAX_SAT],
|
||||||
|
@ -266,9 +264,7 @@ class LightHuePlugin(LightPlugin):
|
||||||
elif not lights:
|
elif not lights:
|
||||||
lights = self.lights
|
lights = self.lights
|
||||||
|
|
||||||
if self.animation_thread and self.animation_thread.is_alive():
|
self.stop_animation()
|
||||||
self.stop_animation()
|
|
||||||
|
|
||||||
self.animation_thread = Thread(target=_animate_thread, args=(lights,))
|
self.animation_thread = Thread(target=_animate_thread, args=(lights,))
|
||||||
self.animation_thread.start()
|
self.animation_thread.start()
|
||||||
return Response(output='ok')
|
return Response(output='ok')
|
||||||
|
|
Loading…
Reference in a new issue