Set config_entry explicitly in todoist coordinator (#129421)

This commit is contained in:
epenet 2024-11-04 19:18:36 +01:00 committed by GitHub
parent b8f2583bc3
commit 2052579efc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 3 deletions

View File

@ -25,7 +25,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
token = entry.data[CONF_TOKEN]
api = TodoistAPIAsync(token)
coordinator = TodoistCoordinator(hass, _LOGGER, SCAN_INTERVAL, api, token)
coordinator = TodoistCoordinator(hass, _LOGGER, entry, SCAN_INTERVAL, api, token)
await coordinator.async_config_entry_first_refresh()
hass.data.setdefault(DOMAIN, {})

View File

@ -142,7 +142,7 @@ async def async_setup_platform(
project_id_lookup = {}
api = TodoistAPIAsync(token)
coordinator = TodoistCoordinator(hass, _LOGGER, SCAN_INTERVAL, api, token)
coordinator = TodoistCoordinator(hass, _LOGGER, None, SCAN_INTERVAL, api, token)
await coordinator.async_refresh()
async def _shutdown_coordinator(_: Event) -> None:

View File

@ -6,6 +6,7 @@ import logging
from todoist_api_python.api_async import TodoistAPIAsync
from todoist_api_python.models import Label, Project, Section, Task
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
@ -17,12 +18,19 @@ class TodoistCoordinator(DataUpdateCoordinator[list[Task]]):
self,
hass: HomeAssistant,
logger: logging.Logger,
entry: ConfigEntry | None,
update_interval: timedelta,
api: TodoistAPIAsync,
token: str,
) -> None:
"""Initialize the Todoist coordinator."""
super().__init__(hass, logger, name="Todoist", update_interval=update_interval)
super().__init__(
hass,
logger,
config_entry=entry,
name="Todoist",
update_interval=update_interval,
)
self.api = api
self._projects: list[Project] | None = None
self._labels: list[Label] | None = None