Use OptionsFlowWithReload in google

This commit is contained in:
G Johansson
2025-08-26 19:58:56 +00:00
parent 87f0703be1
commit af6e2ef3d3
2 changed files with 7 additions and 11 deletions

View File

@@ -134,8 +134,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: GoogleConfigEntry) -> bo
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(async_reload_entry))
return True return True
@@ -151,12 +149,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: GoogleConfigEntry) -> b
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
async def async_reload_entry(hass: HomeAssistant, entry: GoogleConfigEntry) -> None:
"""Reload config entry if the access options change."""
if not async_entry_has_scopes(entry):
await hass.config_entries.async_reload(entry.entry_id)
async def async_remove_entry(hass: HomeAssistant, entry: GoogleConfigEntry) -> None: async def async_remove_entry(hass: HomeAssistant, entry: GoogleConfigEntry) -> None:
"""Handle removal of a local storage.""" """Handle removal of a local storage."""
store = LocalCalendarStore(hass, entry.entry_id) store = LocalCalendarStore(hass, entry.entry_id)

View File

@@ -11,7 +11,11 @@ from gcal_sync.api import GoogleCalendarService
from gcal_sync.exceptions import ApiException, ApiForbiddenException from gcal_sync.exceptions import ApiException, ApiForbiddenException
import voluptuous as vol import voluptuous as vol
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlowResult, OptionsFlow from homeassistant.config_entries import (
SOURCE_REAUTH,
ConfigFlowResult,
OptionsFlowWithReload,
)
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers import config_entry_oauth2_flow from homeassistant.helpers import config_entry_oauth2_flow
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
@@ -237,12 +241,12 @@ class OAuth2FlowHandler(
@callback @callback
def async_get_options_flow( def async_get_options_flow(
config_entry: GoogleConfigEntry, config_entry: GoogleConfigEntry,
) -> OptionsFlow: ) -> OptionsFlowHandler:
"""Create an options flow.""" """Create an options flow."""
return OptionsFlowHandler() return OptionsFlowHandler()
class OptionsFlowHandler(OptionsFlow): class OptionsFlowHandler(OptionsFlowWithReload):
"""Google Calendar options flow.""" """Google Calendar options flow."""
async def async_step_init( async def async_step_init(