Fix lingering timer in cloud (#92498)

This commit is contained in:
epenet 2023-05-04 19:10:44 +02:00 committed by GitHub
parent 7987b00d89
commit 628236209b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -16,7 +16,7 @@ from homeassistant.components.alexa import (
smart_home as alexa_smart_home,
)
from homeassistant.components.google_assistant import smart_home as ga
from homeassistant.core import Context, HomeAssistant, callback
from homeassistant.core import Context, HassJob, HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.event import async_call_later
from homeassistant.util.aiohttp import MockRequest, serialize_response
@ -150,10 +150,12 @@ class CloudClient(Interface):
),
err,
)
async_call_later(self._hass, 30, enable_alexa)
async_call_later(self._hass, 30, enable_alexa_job)
except (alexa_errors.NoTokenAvailable, alexa_errors.RequireRelink):
pass
enable_alexa_job = HassJob(enable_alexa, cancel_on_shutdown=True)
async def enable_google(_):
"""Enable Google."""
gconf = await self.get_google_config()

View file

@ -139,7 +139,9 @@ def async_enable_report_state(hass: HomeAssistant, google_config: AbstractConfig
unsub = async_track_state_change(hass, MATCH_ALL, async_entity_state_listener)
unsub = async_call_later(hass, INITIAL_REPORT_DELAY, initial_report)
unsub = async_call_later(
hass, INITIAL_REPORT_DELAY, HassJob(initial_report, cancel_on_shutdown=True)
)
@callback
def unsub_all():