From c101eb50017d0fdefe4f14114c9b69de972413c6 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 7 Mar 2024 18:37:22 -1000 Subject: [PATCH] Fix homekit_controller delaying startup and shutdown (#112671) The alive poll was scheduled as a tracked task but should have been a background task so it was cancelled. --- .../components/homekit_controller/connection.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/homekit_controller/connection.py b/homeassistant/components/homekit_controller/connection.py index ab5bbc10440..a3c68fffe64 100644 --- a/homeassistant/components/homekit_controller/connection.py +++ b/homeassistant/components/homekit_controller/connection.py @@ -339,8 +339,11 @@ class HKDevice: @callback def _async_schedule_update(self, now: datetime) -> None: """Schedule an update.""" - self.hass.async_create_task( - self._debounced_update.async_call(), eager_start=True + self.config_entry.async_create_background_task( + self.hass, + self._debounced_update.async_call(), + name=f"hkc {self.unique_id} alive poll", + eager_start=True, ) async def async_add_new_entities(self) -> None: @@ -692,8 +695,8 @@ class HKDevice: def process_config_changed(self, config_num: int) -> None: """Handle a config change notification from the pairing.""" - self.hass.async_create_task( - self.async_update_new_accessories_state(), eager_start=True + self.config_entry.async_create_task( + self.hass, self.async_update_new_accessories_state(), eager_start=True ) async def async_update_new_accessories_state(self) -> None: