Explicitly pass in the config_entry in ourgroceries coordinator (#138047)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 15:32:31 +01:00 committed by GitHub
parent 9110557e36
commit e163c15bb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -30,7 +30,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
except InvalidLoginException:
return False
coordinator = OurGroceriesDataUpdateCoordinator(hass, og)
coordinator = OurGroceriesDataUpdateCoordinator(hass, entry, og)
await coordinator.async_config_entry_first_refresh()
hass.data[DOMAIN][entry.entry_id] = coordinator

View File

@ -8,6 +8,7 @@ import logging
from ourgroceries import OurGroceries
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
@ -21,7 +22,11 @@ _LOGGER = logging.getLogger(__name__)
class OurGroceriesDataUpdateCoordinator(DataUpdateCoordinator[dict[str, dict]]):
"""Class to manage fetching OurGroceries data."""
def __init__(self, hass: HomeAssistant, og: OurGroceries) -> None:
config_entry: ConfigEntry
def __init__(
self, hass: HomeAssistant, config_entry: ConfigEntry, og: OurGroceries
) -> None:
"""Initialize global OurGroceries data updater."""
self.og = og
self.lists: list[dict] = []
@ -30,6 +35,7 @@ class OurGroceriesDataUpdateCoordinator(DataUpdateCoordinator[dict[str, dict]]):
super().__init__(
hass,
_LOGGER,
config_entry=config_entry,
name=DOMAIN,
update_interval=interval,
)