Skip to content

Commit

Permalink
Fix lingering timer in cloud (#92498)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet committed May 4, 2023
1 parent 7987b00 commit 6282362
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions homeassistant/components/cloud/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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
Expand Down Expand Up @@ -150,10 +150,12 @@ async def enable_alexa(_):
),
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()
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/google_assistant/report_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ async def initial_report(_now):

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():
Expand Down

0 comments on commit 6282362

Please sign in to comment.