Fix race reloading homekit_controller (#112790)
If the subscribe task was still running during the reload we would not cancel it. Make it a config entry task so it gets cancelled at unload
This commit is contained in:
parent
65358c129a
commit
5b2a24b1bb
1 changed files with 8 additions and 2 deletions
|
@ -197,13 +197,19 @@ class HKDevice:
|
||||||
self._subscribe_timer()
|
self._subscribe_timer()
|
||||||
self._subscribe_timer = None
|
self._subscribe_timer = None
|
||||||
|
|
||||||
async def _async_subscribe(self, _now: datetime) -> None:
|
@callback
|
||||||
|
def _async_subscribe(self, _now: datetime) -> None:
|
||||||
"""Subscribe to characteristics."""
|
"""Subscribe to characteristics."""
|
||||||
self._subscribe_timer = None
|
self._subscribe_timer = None
|
||||||
if self._pending_subscribes:
|
if self._pending_subscribes:
|
||||||
subscribes = self._pending_subscribes.copy()
|
subscribes = self._pending_subscribes.copy()
|
||||||
self._pending_subscribes.clear()
|
self._pending_subscribes.clear()
|
||||||
await self.pairing.subscribe(subscribes)
|
self.config_entry.async_create_task(
|
||||||
|
self.hass,
|
||||||
|
self.pairing.subscribe(subscribes),
|
||||||
|
name=f"hkc subscriptions {self.unique_id}",
|
||||||
|
eager_start=True,
|
||||||
|
)
|
||||||
|
|
||||||
def remove_watchable_characteristics(
|
def remove_watchable_characteristics(
|
||||||
self, characteristics: list[tuple[int, int]]
|
self, characteristics: list[tuple[int, int]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue