Explicitly pass in the config_entry in opengarage coordinator (#138052)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 14:52:19 +01:00 committed by GitHub
parent e050238106
commit 6d776469d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View File

@ -24,8 +24,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async_get_clientsession(hass),
)
open_garage_data_coordinator = OpenGarageDataUpdateCoordinator(
hass,
open_garage_connection=open_garage_connection,
hass, entry, open_garage_connection
)
await open_garage_data_coordinator.async_config_entry_first_refresh()
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = open_garage_data_coordinator

View File

@ -8,6 +8,7 @@ from typing import Any
import opengarage
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers import update_coordinator
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
@ -20,10 +21,12 @@ _LOGGER = logging.getLogger(__name__)
class OpenGarageDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
"""Class to manage fetching Opengarage data."""
config_entry: ConfigEntry
def __init__(
self,
hass: HomeAssistant,
*,
config_entry: ConfigEntry,
open_garage_connection: opengarage.OpenGarage,
) -> None:
"""Initialize global Opengarage data updater."""
@ -32,6 +35,7 @@ class OpenGarageDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
super().__init__(
hass,
_LOGGER,
config_entry=config_entry,
name=DOMAIN,
update_interval=timedelta(seconds=5),
)