mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Explicitly pass in the config_entry in deluge coordinator (#137733)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
2d72b814d6
commit
88a2b2ab90
@ -7,7 +7,6 @@ from ssl import SSLError
|
|||||||
|
|
||||||
from deluge_client.client import DelugeRPCClient
|
from deluge_client.client import DelugeRPCClient
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
@ -19,12 +18,11 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
|
||||||
|
|
||||||
from .const import CONF_WEB_PORT
|
from .const import CONF_WEB_PORT
|
||||||
from .coordinator import DelugeDataUpdateCoordinator
|
from .coordinator import DelugeConfigEntry, DelugeDataUpdateCoordinator
|
||||||
|
|
||||||
PLATFORMS = [Platform.SENSOR, Platform.SWITCH]
|
PLATFORMS = [Platform.SENSOR, Platform.SWITCH]
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
type DelugeConfigEntry = ConfigEntry[DelugeDataUpdateCoordinator]
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: DelugeConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: DelugeConfigEntry) -> bool:
|
||||||
|
@ -4,10 +4,11 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from ssl import SSLError
|
from ssl import SSLError
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import Any
|
||||||
|
|
||||||
from deluge_client.client import DelugeRPCClient, FailedToReconnectException
|
from deluge_client.client import DelugeRPCClient, FailedToReconnectException
|
||||||
|
|
||||||
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||||
@ -15,8 +16,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
|
|||||||
|
|
||||||
from .const import LOGGER, DelugeGetSessionStatusKeys
|
from .const import LOGGER, DelugeGetSessionStatusKeys
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
type DelugeConfigEntry = ConfigEntry[DelugeDataUpdateCoordinator]
|
||||||
from . import DelugeConfigEntry
|
|
||||||
|
|
||||||
|
|
||||||
class DelugeDataUpdateCoordinator(
|
class DelugeDataUpdateCoordinator(
|
||||||
@ -33,11 +33,11 @@ class DelugeDataUpdateCoordinator(
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
hass=hass,
|
hass=hass,
|
||||||
logger=LOGGER,
|
logger=LOGGER,
|
||||||
|
config_entry=entry,
|
||||||
name=entry.title,
|
name=entry.title,
|
||||||
update_interval=timedelta(seconds=30),
|
update_interval=timedelta(seconds=30),
|
||||||
)
|
)
|
||||||
self.api = api
|
self.api = api
|
||||||
self.config_entry = entry
|
|
||||||
|
|
||||||
async def _async_update_data(self) -> dict[Platform, dict[str, Any]]:
|
async def _async_update_data(self) -> dict[Platform, dict[str, Any]]:
|
||||||
"""Get the latest data from Deluge and updates the state."""
|
"""Get the latest data from Deluge and updates the state."""
|
||||||
|
@ -17,9 +17,8 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from . import DelugeConfigEntry
|
|
||||||
from .const import DelugeGetSessionStatusKeys, DelugeSensorType
|
from .const import DelugeGetSessionStatusKeys, DelugeSensorType
|
||||||
from .coordinator import DelugeDataUpdateCoordinator
|
from .coordinator import DelugeConfigEntry, DelugeDataUpdateCoordinator
|
||||||
from .entity import DelugeEntity
|
from .entity import DelugeEntity
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,8 +9,7 @@ from homeassistant.const import Platform
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import DelugeConfigEntry
|
from .coordinator import DelugeConfigEntry, DelugeDataUpdateCoordinator
|
||||||
from .coordinator import DelugeDataUpdateCoordinator
|
|
||||||
from .entity import DelugeEntity
|
from .entity import DelugeEntity
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user