Explicitly pass in the config_entry in deluge coordinator (#137733)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-08 13:22:00 +01:00 committed by GitHub
parent 2d72b814d6
commit 88a2b2ab90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 11 deletions

View File

@ -7,7 +7,6 @@ from ssl import SSLError
from deluge_client.client import DelugeRPCClient
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_HOST,
CONF_PASSWORD,
@ -19,12 +18,11 @@ from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from .const import CONF_WEB_PORT
from .coordinator import DelugeDataUpdateCoordinator
from .coordinator import DelugeConfigEntry, DelugeDataUpdateCoordinator
PLATFORMS = [Platform.SENSOR, Platform.SWITCH]
_LOGGER = logging.getLogger(__name__)
type DelugeConfigEntry = ConfigEntry[DelugeDataUpdateCoordinator]
async def async_setup_entry(hass: HomeAssistant, entry: DelugeConfigEntry) -> bool:

View File

@ -4,10 +4,11 @@ from __future__ import annotations
from datetime import timedelta
from ssl import SSLError
from typing import TYPE_CHECKING, Any
from typing import Any
from deluge_client.client import DelugeRPCClient, FailedToReconnectException
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
@ -15,8 +16,7 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, Upda
from .const import LOGGER, DelugeGetSessionStatusKeys
if TYPE_CHECKING:
from . import DelugeConfigEntry
type DelugeConfigEntry = ConfigEntry[DelugeDataUpdateCoordinator]
class DelugeDataUpdateCoordinator(
@ -33,11 +33,11 @@ class DelugeDataUpdateCoordinator(
super().__init__(
hass=hass,
logger=LOGGER,
config_entry=entry,
name=entry.title,
update_interval=timedelta(seconds=30),
)
self.api = api
self.config_entry = entry
async def _async_update_data(self) -> dict[Platform, dict[str, Any]]:
"""Get the latest data from Deluge and updates the state."""

View File

@ -17,9 +17,8 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
from . import DelugeConfigEntry
from .const import DelugeGetSessionStatusKeys, DelugeSensorType
from .coordinator import DelugeDataUpdateCoordinator
from .coordinator import DelugeConfigEntry, DelugeDataUpdateCoordinator
from .entity import DelugeEntity

View File

@ -9,8 +9,7 @@ from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import DelugeConfigEntry
from .coordinator import DelugeDataUpdateCoordinator
from .coordinator import DelugeConfigEntry, DelugeDataUpdateCoordinator
from .entity import DelugeEntity