Fix dangling task for zha (#88302)

This commit is contained in:
Paulus Schoutsen 2023-02-16 23:07:15 -05:00 committed by GitHub
parent a5170340a3
commit 093f7d6bf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -5,7 +5,6 @@ https://home-assistant.io/integrations/zha/
""" """
from __future__ import annotations from __future__ import annotations
import asyncio
from collections.abc import Callable from collections.abc import Callable
from typing import TYPE_CHECKING, Any from typing import TYPE_CHECKING, Any
@ -351,7 +350,7 @@ class IASZoneChannel(ZigbeeChannel):
elif command_id == 1: elif command_id == 1:
self.debug("Enroll requested") self.debug("Enroll requested")
res = self._cluster.enroll_response(0, 0) res = self._cluster.enroll_response(0, 0)
asyncio.create_task(res) self._cluster.create_catching_task(res)
async def async_configure(self): async def async_configure(self):
"""Configure IAS device.""" """Configure IAS device."""

View File

@ -254,7 +254,9 @@ class ZHAGateway:
) )
# background the fetching of state for mains powered devices # background the fetching of state for mains powered devices
asyncio.create_task(fetch_updated_state()) self._hass.async_create_background_task(
fetch_updated_state(), "zha.gateway-fetch_updated_state"
)
def device_joined(self, device: zigpy.device.Device) -> None: def device_joined(self, device: zigpy.device.Device) -> None:
"""Handle device joined. """Handle device joined.

View File

@ -1,7 +1,6 @@
"""Lights on Zigbee Home Automation networks.""" """Lights on Zigbee Home Automation networks."""
from __future__ import annotations from __future__ import annotations
import asyncio
from collections import Counter from collections import Counter
from collections.abc import Callable from collections.abc import Callable
from datetime import timedelta from datetime import timedelta
@ -613,7 +612,10 @@ class BaseLight(LogMixin, light.LightEntity):
) )
if self._debounced_member_refresh is not None: if self._debounced_member_refresh is not None:
self.debug("transition complete - refreshing group member states") self.debug("transition complete - refreshing group member states")
asyncio.create_task(self._debounced_member_refresh.async_call()) self.hass.async_create_background_task(
self._debounced_member_refresh.async_call(),
"zha.light-refresh-debounced-member",
)
@STRICT_MATCH(channel_names=CHANNEL_ON_OFF, aux_channels={CHANNEL_COLOR, CHANNEL_LEVEL}) @STRICT_MATCH(channel_names=CHANNEL_ON_OFF, aux_channels={CHANNEL_COLOR, CHANNEL_LEVEL})