Skip to content
Snippets Groups Projects
Unverified Commit e7d49823 authored by Michael's avatar Michael Committed by GitHub
Browse files

Explicitly pass in the config_entry in islamic_prayer_times coordinator (#138133)

explicitly pass in the config_entry in coordinator
parent 4eccc9d9
No related branches found
No related tags found
No related merge requests found
...@@ -4,20 +4,20 @@ from __future__ import annotations ...@@ -4,20 +4,20 @@ from __future__ import annotations
import logging import logging
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, Platform from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, Platform
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
from .coordinator import IslamicPrayerDataUpdateCoordinator from .coordinator import (
IslamicPrayerDataUpdateCoordinator,
IslamicPrayerTimesConfigEntry,
)
PLATFORMS = [Platform.SENSOR] PLATFORMS = [Platform.SENSOR]
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
type IslamicPrayerTimesConfigEntry = ConfigEntry[IslamicPrayerDataUpdateCoordinator]
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, config_entry: IslamicPrayerTimesConfigEntry hass: HomeAssistant, config_entry: IslamicPrayerTimesConfigEntry
...@@ -36,7 +36,7 @@ async def async_setup_entry( ...@@ -36,7 +36,7 @@ async def async_setup_entry(
await er.async_migrate_entries(hass, config_entry.entry_id, update_unique_id) 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() await coordinator.async_config_entry_first_refresh()
config_entry.runtime_data = coordinator config_entry.runtime_data = coordinator
...@@ -48,7 +48,9 @@ async def async_setup_entry( ...@@ -48,7 +48,9 @@ async def async_setup_entry(
return True 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.""" """Migrate old entry."""
_LOGGER.debug("Migrating from version %s", config_entry.version) _LOGGER.debug("Migrating from version %s", config_entry.version)
......
...@@ -29,21 +29,26 @@ from .const import ( ...@@ -29,21 +29,26 @@ from .const import (
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
type IslamicPrayerTimesConfigEntry = ConfigEntry[IslamicPrayerDataUpdateCoordinator]
class IslamicPrayerDataUpdateCoordinator(DataUpdateCoordinator[dict[str, datetime]]): class IslamicPrayerDataUpdateCoordinator(DataUpdateCoordinator[dict[str, datetime]]):
"""Islamic Prayer Client Object.""" """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.""" """Initialize the Islamic Prayer client."""
super().__init__( super().__init__(
hass, hass,
_LOGGER, _LOGGER,
config_entry=config_entry,
name=DOMAIN, name=DOMAIN,
) )
self.latitude = self.config_entry.data[CONF_LATITUDE] self.latitude = config_entry.data[CONF_LATITUDE]
self.longitude = self.config_entry.data[CONF_LONGITUDE] self.longitude = config_entry.data[CONF_LONGITUDE]
self.event_unsub: CALLBACK_TYPE | None = None self.event_unsub: CALLBACK_TYPE | None = None
@property @property
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment