LIFX: fix color restore after running effects
State restoration takes up to a second because bulbs can be slow to react. During this time an effect could keep running, overwriting the state that we were trying to restore. Now the effect forgets the light immediately and it thus avoids further changes while the restored state settles.pull/7446/head
parent
71d909483c
commit
99e34539b9
|
@ -196,18 +196,19 @@ class LIFXEffect(object):
|
|||
@asyncio.coroutine
|
||||
def async_restore(self, light):
|
||||
"""Restore to the original state (if we are still running)."""
|
||||
if light.effect_data:
|
||||
if light.effect_data.effect == self:
|
||||
if light.device and not light.effect_data.power:
|
||||
light.device.set_power(False)
|
||||
yield from asyncio.sleep(0.5)
|
||||
if light.device:
|
||||
light.device.set_color(light.effect_data.color)
|
||||
yield from asyncio.sleep(0.5)
|
||||
light.effect_data = None
|
||||
yield from light.refresh_state()
|
||||
if light in self.lights:
|
||||
self.lights.remove(light)
|
||||
|
||||
if light.effect_data and light.effect_data.effect == self:
|
||||
if light.device and not light.effect_data.power:
|
||||
light.device.set_power(False)
|
||||
yield from asyncio.sleep(0.5)
|
||||
if light.device:
|
||||
light.device.set_color(light.effect_data.color)
|
||||
yield from asyncio.sleep(0.5)
|
||||
light.effect_data = None
|
||||
yield from light.refresh_state()
|
||||
|
||||
def from_poweroff_hsbk(self, light, **kwargs):
|
||||
"""Return the color when starting from a powered off state."""
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue