Skip to content

Commit

Permalink
Fix lingering timer in lifx (home-assistant#92476)
Browse files Browse the repository at this point in the history
* Fix lingering timer in lifx

* Remove duplicate code
  • Loading branch information
epenet authored May 4, 2023
1 parent a73a66b commit 8a9b9c3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions homeassistant/components/lifx/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ def effect(self) -> str | None:

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()
Expand Down Expand Up @@ -327,6 +325,17 @@ async def async_added_to_hass(self) -> None:
)
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."""
Expand Down

0 comments on commit 8a9b9c3

Please sign in to comment.