From 88a2b2ab90c72675d2065e5dc5a3c11ca4c3e658 Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Sat, 8 Feb 2025 13:22:00 +0100 Subject: [PATCH] Explicitly pass in the config_entry in deluge coordinator (#137733) explicitly pass in the config_entry in coordinator --- homeassistant/components/deluge/__init__.py | 4 +--- homeassistant/components/deluge/coordinator.py | 8 ++++---- homeassistant/components/deluge/sensor.py | 3 +-- homeassistant/components/deluge/switch.py | 3 +-- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/deluge/__init__.py b/homeassistant/components/deluge/__init__.py index 9b07ae9c875..f9972570df3 100644 --- a/homeassistant/components/deluge/__init__.py +++ b/homeassistant/components/deluge/__init__.py @@ -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: diff --git a/homeassistant/components/deluge/coordinator.py b/homeassistant/components/deluge/coordinator.py index 7f4bf9e884e..c5836243b9d 100644 --- a/homeassistant/components/deluge/coordinator.py +++ b/homeassistant/components/deluge/coordinator.py @@ -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.""" diff --git a/homeassistant/components/deluge/sensor.py b/homeassistant/components/deluge/sensor.py index 5ebf3d01eeb..24d5ce9ec61 100644 --- a/homeassistant/components/deluge/sensor.py +++ b/homeassistant/components/deluge/sensor.py @@ -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 diff --git a/homeassistant/components/deluge/switch.py b/homeassistant/components/deluge/switch.py index d81f02eee29..1ec0cd7a7df 100644 --- a/homeassistant/components/deluge/switch.py +++ b/homeassistant/components/deluge/switch.py @@ -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