diff --git a/homeassistant/components/lifx/light.py b/homeassistant/components/lifx/light.py index dd4e50d8f16..4f4223817bc 100644 --- a/homeassistant/components/lifx/light.py +++ b/homeassistant/components/lifx/light.py @@ -170,9 +170,7 @@ class LIFXLight(LIFXEntity, LightEntity): async def update_during_transition(self, when: int) -> None: """Update state at the start and end of a transition.""" - if self.postponed_update: - self.postponed_update() - self.postponed_update = None + self._cancel_postponed_update() # Transition has started self.async_write_ha_state() @@ -327,6 +325,17 @@ class LIFXLight(LIFXEntity, LightEntity): ) return await super().async_added_to_hass() + def _cancel_postponed_update(self) -> None: + """Cancel postponed update, if applicable.""" + if self.postponed_update: + self.postponed_update() + self.postponed_update = None + + async def async_will_remove_from_hass(self) -> None: + """Run when entity will be removed from hass.""" + self._cancel_postponed_update() + return await super().async_will_remove_from_hass() + class LIFXWhite(LIFXLight): """Representation of a white-only LIFX light."""