mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Explicitly pass in the config_entry in google_tasks coordinator (#137842)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
c9ffeb8007
commit
846797a394
@ -13,9 +13,8 @@ from homeassistant.helpers import config_entry_oauth2_flow
|
|||||||
|
|
||||||
from . import api
|
from . import api
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .coordinator import TaskUpdateCoordinator
|
from .coordinator import GoogleTasksConfigEntry, TaskUpdateCoordinator
|
||||||
from .exceptions import GoogleTasksApiError
|
from .exceptions import GoogleTasksApiError
|
||||||
from .types import GoogleTasksConfigEntry
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"DOMAIN",
|
"DOMAIN",
|
||||||
@ -52,6 +51,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: GoogleTasksConfigEntry)
|
|||||||
coordinators = [
|
coordinators = [
|
||||||
TaskUpdateCoordinator(
|
TaskUpdateCoordinator(
|
||||||
hass,
|
hass,
|
||||||
|
entry,
|
||||||
auth,
|
auth,
|
||||||
task_list["id"],
|
task_list["id"],
|
||||||
task_list["title"],
|
task_list["title"],
|
||||||
|
@ -5,6 +5,7 @@ import datetime
|
|||||||
import logging
|
import logging
|
||||||
from typing import Any, Final
|
from typing import Any, Final
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
|
||||||
@ -15,13 +16,18 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
UPDATE_INTERVAL: Final = datetime.timedelta(minutes=30)
|
UPDATE_INTERVAL: Final = datetime.timedelta(minutes=30)
|
||||||
TIMEOUT = 10
|
TIMEOUT = 10
|
||||||
|
|
||||||
|
type GoogleTasksConfigEntry = ConfigEntry[list[TaskUpdateCoordinator]]
|
||||||
|
|
||||||
|
|
||||||
class TaskUpdateCoordinator(DataUpdateCoordinator[list[dict[str, Any]]]):
|
class TaskUpdateCoordinator(DataUpdateCoordinator[list[dict[str, Any]]]):
|
||||||
"""Coordinator for fetching Google Tasks for a Task List form the API."""
|
"""Coordinator for fetching Google Tasks for a Task List form the API."""
|
||||||
|
|
||||||
|
config_entry: GoogleTasksConfigEntry
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
|
config_entry: GoogleTasksConfigEntry,
|
||||||
api: AsyncConfigEntryAuth,
|
api: AsyncConfigEntryAuth,
|
||||||
task_list_id: str,
|
task_list_id: str,
|
||||||
task_list_title: str,
|
task_list_title: str,
|
||||||
@ -30,6 +36,7 @@ class TaskUpdateCoordinator(DataUpdateCoordinator[list[dict[str, Any]]]):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
hass,
|
hass,
|
||||||
_LOGGER,
|
_LOGGER,
|
||||||
|
config_entry=config_entry,
|
||||||
name=f"Google Tasks {task_list_id}",
|
name=f"Google Tasks {task_list_id}",
|
||||||
update_interval=UPDATE_INTERVAL,
|
update_interval=UPDATE_INTERVAL,
|
||||||
)
|
)
|
||||||
|
@ -16,8 +16,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
|
|
||||||
from .coordinator import TaskUpdateCoordinator
|
from .coordinator import GoogleTasksConfigEntry, TaskUpdateCoordinator
|
||||||
from .types import GoogleTasksConfigEntry
|
|
||||||
|
|
||||||
PARALLEL_UPDATES = 0
|
PARALLEL_UPDATES = 0
|
||||||
|
|
||||||
|
@ -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]]
|
|
Loading…
x
Reference in New Issue
Block a user