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 nzbget coordinator (#138061)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
7097faa950
commit
8241429c5e
@ -31,10 +31,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
"""Set up NZBGet from a config entry."""
|
||||
hass.data.setdefault(DOMAIN, {})
|
||||
|
||||
coordinator = NZBGetDataUpdateCoordinator(
|
||||
hass,
|
||||
config=entry.data,
|
||||
)
|
||||
coordinator = NZBGetDataUpdateCoordinator(hass, entry)
|
||||
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
|
||||
|
@ -1,13 +1,12 @@
|
||||
"""Provides the NZBGet DataUpdateCoordinator."""
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Mapping
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pynzbgetapi import NZBGetAPI, NZBGetAPIException
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_PASSWORD,
|
||||
@ -27,27 +26,32 @@ _LOGGER = logging.getLogger(__name__)
|
||||
class NZBGetDataUpdateCoordinator(DataUpdateCoordinator):
|
||||
"""Class to manage fetching NZBGet data."""
|
||||
|
||||
config_entry: ConfigEntry
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
*,
|
||||
config: Mapping[str, Any],
|
||||
config_entry: ConfigEntry,
|
||||
) -> None:
|
||||
"""Initialize global NZBGet data updater."""
|
||||
self.nzbget = NZBGetAPI(
|
||||
config[CONF_HOST],
|
||||
config.get(CONF_USERNAME),
|
||||
config.get(CONF_PASSWORD),
|
||||
config[CONF_SSL],
|
||||
config[CONF_VERIFY_SSL],
|
||||
config[CONF_PORT],
|
||||
config_entry.data[CONF_HOST],
|
||||
config_entry.data.get(CONF_USERNAME),
|
||||
config_entry.data.get(CONF_PASSWORD),
|
||||
config_entry.data[CONF_SSL],
|
||||
config_entry.data[CONF_VERIFY_SSL],
|
||||
config_entry.data[CONF_PORT],
|
||||
)
|
||||
|
||||
self._completed_downloads_init = False
|
||||
self._completed_downloads = set[tuple]()
|
||||
|
||||
super().__init__(
|
||||
hass, _LOGGER, name=DOMAIN, update_interval=timedelta(seconds=5)
|
||||
hass,
|
||||
_LOGGER,
|
||||
config_entry=config_entry,
|
||||
name=DOMAIN,
|
||||
update_interval=timedelta(seconds=5),
|
||||
)
|
||||
|
||||
def _check_completed_downloads(self, history):
|
||||
|
Loading…
x
Reference in New Issue
Block a user