forked from platypush/platypush
Animation thread wrapped in a try-except to prevent the thread from exiting in case of temporary errors
This commit is contained in:
parent
61e211ee07
commit
6ebab5de25
1 changed files with 19 additions and 15 deletions
|
@ -502,23 +502,27 @@ class LightHuePlugin(LightPlugin):
|
||||||
(duration and time.time() - animation_start_time > duration):
|
(duration and time.time() - animation_start_time > duration):
|
||||||
break
|
break
|
||||||
|
|
||||||
if animation == self.Animation.COLOR_TRANSITION:
|
try:
|
||||||
for (light, attrs) in lights.items():
|
if animation == self.Animation.COLOR_TRANSITION:
|
||||||
self.logger.info('Setting {} to {}'.format(light, attrs))
|
for (light, attrs) in lights.items():
|
||||||
self.bridge.set_light(light, attrs)
|
self.logger.info('Setting {} to {}'.format(light, attrs))
|
||||||
|
self.bridge.set_light(light, attrs)
|
||||||
|
stop_animation = _should_stop()
|
||||||
|
if stop_animation: break
|
||||||
|
elif animation == self.Animation.BLINK:
|
||||||
|
conf = lights[list(lights.keys())[0]]
|
||||||
|
self.logger.info('Setting lights to {}'.format(conf))
|
||||||
|
|
||||||
|
if groups:
|
||||||
|
self.bridge.set_group([g.name for f in groups], conf)
|
||||||
|
else:
|
||||||
|
self.bridge.set_light(lights.keys(), conf)
|
||||||
|
|
||||||
stop_animation = _should_stop()
|
stop_animation = _should_stop()
|
||||||
if stop_animation: break
|
if stop_animation: break
|
||||||
elif animation == self.Animation.BLINK:
|
except Exception as e:
|
||||||
conf = lights[list(lights.keys())[0]]
|
self.logger.warning(e)
|
||||||
self.logger.info('Setting lights to {}'.format(conf))
|
time.sleep(2)
|
||||||
|
|
||||||
if groups:
|
|
||||||
self.bridge.set_group([g.name for f in groups], conf)
|
|
||||||
else:
|
|
||||||
self.bridge.set_light(lights.keys(), conf)
|
|
||||||
|
|
||||||
stop_animation = _should_stop()
|
|
||||||
if stop_animation: break
|
|
||||||
|
|
||||||
lights = _next_light_attrs(lights)
|
lights = _next_light_attrs(lights)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue