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,
CalendarEvent,
)
from homeassistant.const import CONF_ID, CONF_NAME, CONF_TOKEN
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.const import CONF_ID, CONF_NAME, CONF_TOKEN, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import Event, HomeAssistant, ServiceCall
from homeassistant.helpers.aiohttp_client import async_get_clientsession
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -122,6 +122,11 @@ async def async_setup_platform(
coordinator = TodoistCoordinator(hass, _LOGGER, SCAN_INTERVAL, api)
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:
# Grab all projects.
projects = await api.get_projects()