mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Do not cache the reconfigure entry in holiday config flow (#128005)
This commit is contained in:
parent
253a5e3e4b
commit
ac7dc03603
@ -8,7 +8,7 @@ from babel import Locale, UnknownLocaleError
|
|||||||
from holidays import list_supported_countries
|
from holidays import list_supported_countries
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_COUNTRY
|
from homeassistant.const import CONF_COUNTRY
|
||||||
from homeassistant.helpers.selector import (
|
from homeassistant.helpers.selector import (
|
||||||
CountrySelector,
|
CountrySelector,
|
||||||
@ -27,7 +27,6 @@ class HolidayConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle a config flow for Holiday."""
|
"""Handle a config flow for Holiday."""
|
||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
config_entry: ConfigEntry
|
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Initialize the config flow."""
|
"""Initialize the config flow."""
|
||||||
@ -115,15 +114,15 @@ class HolidayConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the re-configuration of a province."""
|
"""Handle the re-configuration of a province."""
|
||||||
self.config_entry = self._get_reconfigure_entry()
|
|
||||||
return await self.async_step_reconfigure_confirm()
|
return await self.async_step_reconfigure_confirm()
|
||||||
|
|
||||||
async def async_step_reconfigure_confirm(
|
async def async_step_reconfigure_confirm(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle the re-configuration of a province."""
|
"""Handle the re-configuration of a province."""
|
||||||
|
reconfigure_entry = self._get_reconfigure_entry()
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
combined_input: dict[str, Any] = {**self.config_entry.data, **user_input}
|
combined_input: dict[str, Any] = {**reconfigure_entry.data, **user_input}
|
||||||
|
|
||||||
country = combined_input[CONF_COUNTRY]
|
country = combined_input[CONF_COUNTRY]
|
||||||
province = combined_input.get(CONF_PROVINCE)
|
province = combined_input.get(CONF_PROVINCE)
|
||||||
@ -145,10 +144,7 @@ class HolidayConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
name = f"{locale.territories[country]}{province_str}"
|
name = f"{locale.territories[country]}{province_str}"
|
||||||
|
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(
|
||||||
self.config_entry,
|
reconfigure_entry, title=name, data=combined_input
|
||||||
title=name,
|
|
||||||
data=combined_input,
|
|
||||||
reason="reconfigure_successful",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
province_schema = vol.Schema(
|
province_schema = vol.Schema(
|
||||||
@ -156,7 +152,7 @@ class HolidayConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
vol.Optional(CONF_PROVINCE): SelectSelector(
|
vol.Optional(CONF_PROVINCE): SelectSelector(
|
||||||
SelectSelectorConfig(
|
SelectSelectorConfig(
|
||||||
options=SUPPORTED_COUNTRIES[
|
options=SUPPORTED_COUNTRIES[
|
||||||
self.config_entry.data[CONF_COUNTRY]
|
reconfigure_entry.data[CONF_COUNTRY]
|
||||||
],
|
],
|
||||||
mode=SelectSelectorMode.DROPDOWN,
|
mode=SelectSelectorMode.DROPDOWN,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user