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