Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lingering timer in lifx discovery #92185

Merged
merged 1 commit into from
Apr 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions homeassistant/components/lifx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
EVENT_HOMEASSISTANT_STARTED,
Platform,
)
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
from homeassistant.core import CALLBACK_TYPE, HassJob, HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_call_later, async_track_time_interval
Expand Down Expand Up @@ -125,7 +125,7 @@ def async_setup_discovery_interval(self) -> None:
self.migrating,
)
self._cancel_discovery = async_track_time_interval(
self.hass, self.async_discovery, discovery_interval
self.hass, self.async_discovery, discovery_interval, cancel_on_shutdown=True
)

async def async_discovery(self, *_: Any) -> None:
Expand Down Expand Up @@ -174,7 +174,11 @@ def _async_delayed_discovery(now: datetime) -> None:
# to reduce the risk we miss devices because the event
# loop is blocked at startup.
discovery_manager.async_setup_discovery_interval()
async_call_later(hass, DISCOVERY_COOLDOWN, _async_delayed_discovery)
async_call_later(
hass,
DISCOVERY_COOLDOWN,
HassJob(_async_delayed_discovery, cancel_on_shutdown=True),
)
hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_STARTED, discovery_manager.async_discovery
)
Expand Down