Fix lingering timer in todoist (#91808)

This commit is contained in:
epenet 2023-04-21 16:41:54 +02:00 committed by GitHub
parent 93eac97983
commit 07aef27ea8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,8 +17,8 @@ from homeassistant.components.calendar import (
CalendarEntity, CalendarEntity,
CalendarEvent, CalendarEvent,
) )
from homeassistant.const import CONF_ID, CONF_NAME, CONF_TOKEN from homeassistant.const import CONF_ID, CONF_NAME, CONF_TOKEN, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.core import Event, HomeAssistant, ServiceCall
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -122,6 +122,11 @@ async def async_setup_platform(
coordinator = TodoistCoordinator(hass, _LOGGER, SCAN_INTERVAL, api) coordinator = TodoistCoordinator(hass, _LOGGER, SCAN_INTERVAL, api)
await coordinator.async_config_entry_first_refresh() await coordinator.async_config_entry_first_refresh()
async def _shutdown_coordinator(_: Event) -> None:
await coordinator.async_shutdown()
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _shutdown_coordinator)
# Setup devices: # Setup devices:
# Grab all projects. # Grab all projects.
projects = await api.get_projects() projects = await api.get_projects()