Use OptionsFlowWithReload in lastfm (#149113)

This commit is contained in:
G Johansson 2025-07-20 12:05:24 +02:00 committed by GitHub
parent ead99c549f
commit b262a5c9b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 8 deletions

View File

@ -16,7 +16,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: LastFMConfigEntry) -> bo
entry.runtime_data = coordinator entry.runtime_data = coordinator
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
entry.async_on_unload(entry.add_update_listener(update_listener))
return True return True
@ -24,8 +23,3 @@ async def async_setup_entry(hass: HomeAssistant, entry: LastFMConfigEntry) -> bo
async def async_unload_entry(hass: HomeAssistant, entry: LastFMConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: LastFMConfigEntry) -> bool:
"""Unload lastfm config entry.""" """Unload lastfm config entry."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
async def update_listener(hass: HomeAssistant, entry: LastFMConfigEntry) -> None:
"""Handle options update."""
await hass.config_entries.async_reload(entry.entry_id)

View File

@ -8,7 +8,11 @@ from typing import Any
from pylast import LastFMNetwork, PyLastError, User, WSError from pylast import LastFMNetwork, PyLastError, User, WSError
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult, OptionsFlow from homeassistant.config_entries import (
ConfigFlow,
ConfigFlowResult,
OptionsFlowWithReload,
)
from homeassistant.const import CONF_API_KEY from homeassistant.const import CONF_API_KEY
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers.selector import ( from homeassistant.helpers.selector import (
@ -155,7 +159,7 @@ class LastFmConfigFlowHandler(ConfigFlow, domain=DOMAIN):
) )
class LastFmOptionsFlowHandler(OptionsFlow): class LastFmOptionsFlowHandler(OptionsFlowWithReload):
"""LastFm Options flow handler.""" """LastFm Options flow handler."""
config_entry: LastFMConfigEntry config_entry: LastFMConfigEntry