mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Explicitly pass in the config_entry in islamic_prayer_times coordinator (#138133)
explicitly pass in the config_entry in coordinator
This commit is contained in:
parent
4eccc9d9a4
commit
e7d49823e4
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user