Explicitly pass in the config_entry in lastfm coordinator (#138117)

explicitly pass in the config_entry in coordinator
This commit is contained in:
Michael 2025-02-09 20:08:44 +01:00 committed by GitHub
parent 8234c9a183
commit b9fd5d01dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -12,7 +12,7 @@ from .coordinator import LastFMDataUpdateCoordinator
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up lastfm from a config entry."""
coordinator = LastFMDataUpdateCoordinator(hass)
coordinator = LastFMDataUpdateCoordinator(hass, entry)
await coordinator.async_config_entry_first_refresh()
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator

View File

@ -39,15 +39,16 @@ class LastFMDataUpdateCoordinator(DataUpdateCoordinator[dict[str, LastFMUserData
config_entry: ConfigEntry
_client: LastFMNetwork
def __init__(self, hass: HomeAssistant) -> None:
def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry) -> None:
"""Initialize the LastFM data coordinator."""
super().__init__(
hass,
LOGGER,
config_entry=config_entry,
name=DOMAIN,
update_interval=timedelta(seconds=30),
)
self._client = LastFMNetwork(api_key=self.config_entry.options[CONF_API_KEY])
self._client = LastFMNetwork(api_key=config_entry.options[CONF_API_KEY])
async def _async_update_data(self) -> dict[str, LastFMUserData]:
res = {}