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.
This commit is contained in:
J. Nick Koston 2024-03-07 18:37:22 -10:00 committed by GitHub
parent a6b17dbe68
commit c101eb5001
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -339,8 +339,11 @@ class HKDevice:
@callback @callback
def _async_schedule_update(self, now: datetime) -> None: def _async_schedule_update(self, now: datetime) -> None:
"""Schedule an update.""" """Schedule an update."""
self.hass.async_create_task( self.config_entry.async_create_background_task(
self._debounced_update.async_call(), eager_start=True 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: async def async_add_new_entities(self) -> None:
@ -692,8 +695,8 @@ class HKDevice:
def process_config_changed(self, config_num: int) -> None: def process_config_changed(self, config_num: int) -> None:
"""Handle a config change notification from the pairing.""" """Handle a config change notification from the pairing."""
self.hass.async_create_task( self.config_entry.async_create_task(
self.async_update_new_accessories_state(), eager_start=True self.hass, self.async_update_new_accessories_state(), eager_start=True
) )
async def async_update_new_accessories_state(self) -> None: async def async_update_new_accessories_state(self) -> None: