From e7d49823e49dcadb26a808a1daf92fa30f9b438a Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Sun, 9 Feb 2025 21:01:44 +0100 Subject: [PATCH] Explicitly pass in the config_entry in islamic_prayer_times coordinator (#138133) explicitly pass in the config_entry in coordinator --- .../components/islamic_prayer_times/__init__.py | 14 ++++++++------ .../components/islamic_prayer_times/coordinator.py | 13 +++++++++---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/islamic_prayer_times/__init__.py b/homeassistant/components/islamic_prayer_times/__init__.py index d61eba343ac..731d1324c71 100644 --- a/homeassistant/components/islamic_prayer_times/__init__.py +++ b/homeassistant/components/islamic_prayer_times/__init__.py @@ -4,20 +4,20 @@ from __future__ import annotations import logging -from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, Platform from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import entity_registry as er -from .coordinator import IslamicPrayerDataUpdateCoordinator +from .coordinator import ( + IslamicPrayerDataUpdateCoordinator, + IslamicPrayerTimesConfigEntry, +) PLATFORMS = [Platform.SENSOR] _LOGGER = logging.getLogger(__name__) -type IslamicPrayerTimesConfigEntry = ConfigEntry[IslamicPrayerDataUpdateCoordinator] - async def async_setup_entry( hass: HomeAssistant, config_entry: IslamicPrayerTimesConfigEntry @@ -36,7 +36,7 @@ async def async_setup_entry( await er.async_migrate_entries(hass, config_entry.entry_id, update_unique_id) - coordinator = IslamicPrayerDataUpdateCoordinator(hass) + coordinator = IslamicPrayerDataUpdateCoordinator(hass, config_entry) await coordinator.async_config_entry_first_refresh() config_entry.runtime_data = coordinator @@ -48,7 +48,9 @@ async def async_setup_entry( return True -async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: +async def async_migrate_entry( + hass: HomeAssistant, config_entry: IslamicPrayerTimesConfigEntry +) -> bool: """Migrate old entry.""" _LOGGER.debug("Migrating from version %s", config_entry.version) diff --git a/homeassistant/components/islamic_prayer_times/coordinator.py b/homeassistant/components/islamic_prayer_times/coordinator.py index 35903afa393..a6cd3fb151e 100644 --- a/homeassistant/components/islamic_prayer_times/coordinator.py +++ b/homeassistant/components/islamic_prayer_times/coordinator.py @@ -29,21 +29,26 @@ from .const import ( _LOGGER = logging.getLogger(__name__) +type IslamicPrayerTimesConfigEntry = ConfigEntry[IslamicPrayerDataUpdateCoordinator] + class IslamicPrayerDataUpdateCoordinator(DataUpdateCoordinator[dict[str, datetime]]): """Islamic Prayer Client Object.""" - config_entry: ConfigEntry + config_entry: IslamicPrayerTimesConfigEntry - def __init__(self, hass: HomeAssistant) -> None: + def __init__( + self, hass: HomeAssistant, config_entry: IslamicPrayerTimesConfigEntry + ) -> None: """Initialize the Islamic Prayer client.""" super().__init__( hass, _LOGGER, + config_entry=config_entry, name=DOMAIN, ) - self.latitude = self.config_entry.data[CONF_LATITUDE] - self.longitude = self.config_entry.data[CONF_LONGITUDE] + self.latitude = config_entry.data[CONF_LATITUDE] + self.longitude = config_entry.data[CONF_LONGITUDE] self.event_unsub: CALLBACK_TYPE | None = None @property -- GitLab