Explicitly pass in the config_entry in google_tasks coordinator (#137842)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-08 15:33:21 +01:00 committed by GitHub
parent c9ffeb8007
commit 846797a394
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 11 deletions

View File

@ -13,9 +13,8 @@ from homeassistant.helpers import config_entry_oauth2_flow
from . import api
from .const import DOMAIN
from .coordinator import TaskUpdateCoordinator
from .coordinator import GoogleTasksConfigEntry, TaskUpdateCoordinator
from .exceptions import GoogleTasksApiError
from .types import GoogleTasksConfigEntry
__all__ = [
"DOMAIN",
@ -52,6 +51,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: GoogleTasksConfigEntry)
coordinators = [
TaskUpdateCoordinator(
hass,
entry,
auth,
task_list["id"],
task_list["title"],

View File

@ -5,6 +5,7 @@ import datetime
import logging
from typing import Any, Final
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
@ -15,13 +16,18 @@ _LOGGER = logging.getLogger(__name__)
UPDATE_INTERVAL: Final = datetime.timedelta(minutes=30)
TIMEOUT = 10
type GoogleTasksConfigEntry = ConfigEntry[list[TaskUpdateCoordinator]]
class TaskUpdateCoordinator(DataUpdateCoordinator[list[dict[str, Any]]]):
"""Coordinator for fetching Google Tasks for a Task List form the API."""
config_entry: GoogleTasksConfigEntry
def __init__(
self,
hass: HomeAssistant,
config_entry: GoogleTasksConfigEntry,
api: AsyncConfigEntryAuth,
task_list_id: str,
task_list_title: str,
@ -30,6 +36,7 @@ class TaskUpdateCoordinator(DataUpdateCoordinator[list[dict[str, Any]]]):
super().__init__(
hass,
_LOGGER,
config_entry=config_entry,
name=f"Google Tasks {task_list_id}",
update_interval=UPDATE_INTERVAL,
)

View File

@ -16,8 +16,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.util import dt as dt_util
from .coordinator import TaskUpdateCoordinator
from .types import GoogleTasksConfigEntry
from .coordinator import GoogleTasksConfigEntry, TaskUpdateCoordinator
PARALLEL_UPDATES = 0

View File

@ -1,7 +0,0 @@
"""Types for the Google Tasks integration."""
from homeassistant.config_entries import ConfigEntry
from .coordinator import TaskUpdateCoordinator
type GoogleTasksConfigEntry = ConfigEntry[list[TaskUpdateCoordinator]]