Explicitly pass in the config_entry in spotify coordinator (#137935)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 14:55:16 +01:00 committed by GitHub
parent 1976fdfa55
commit 62461d7525
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 4 deletions

View File

@ -8,7 +8,6 @@ from typing import TYPE_CHECKING
import aiohttp
from spotifyaio import Device, SpotifyClient, SpotifyConnectionError
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ACCESS_TOKEN, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
@ -63,7 +62,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: SpotifyConfigEntry) -> b
spotify.refresh_token_function = _refresh_token
coordinator = SpotifyCoordinator(hass, spotify)
coordinator = SpotifyCoordinator(hass, entry, spotify)
await coordinator.async_config_entry_first_refresh()
@ -92,6 +91,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: SpotifyConfigEntry) -> b
return True
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_unload_entry(hass: HomeAssistant, entry: SpotifyConfigEntry) -> bool:
"""Unload Spotify config entry."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

View File

@ -56,11 +56,17 @@ class SpotifyCoordinator(DataUpdateCoordinator[SpotifyCoordinatorData]):
current_user: UserProfile
config_entry: SpotifyConfigEntry
def __init__(self, hass: HomeAssistant, client: SpotifyClient) -> None:
def __init__(
self,
hass: HomeAssistant,
config_entry: SpotifyConfigEntry,
client: SpotifyClient,
) -> None:
"""Initialize."""
super().__init__(
hass,
_LOGGER,
config_entry=config_entry,
name=DOMAIN,
update_interval=UPDATE_INTERVAL,
)