Do not cache reconfigure entry in vallox config flow (#128029)
This commit is contained in:
parent
577ae6923a
commit
c8178ab915
1 changed files with 5 additions and 9 deletions
|
@ -8,7 +8,7 @@ from typing import Any
|
|||
from vallox_websocket_api import Vallox, ValloxApiException
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
|
@ -40,8 +40,6 @@ class ValloxConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
|
||||
VERSION = 1
|
||||
|
||||
_context_entry: ConfigEntry
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
|
@ -88,24 +86,24 @@ class ValloxConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle reconfiguration of the Vallox device host address."""
|
||||
self._context_entry = self._get_reconfigure_entry()
|
||||
return await self.async_step_reconfigure_confirm()
|
||||
|
||||
async def async_step_reconfigure_confirm(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle reconfiguration of the Vallox device host address."""
|
||||
reconfigure_entry = self._get_reconfigure_entry()
|
||||
if not user_input:
|
||||
return self.async_show_form(
|
||||
step_id="reconfigure_confirm",
|
||||
data_schema=self.add_suggested_values_to_schema(
|
||||
CONFIG_SCHEMA, {CONF_HOST: self._context_entry.data.get(CONF_HOST)}
|
||||
CONFIG_SCHEMA, {CONF_HOST: reconfigure_entry.data.get(CONF_HOST)}
|
||||
),
|
||||
)
|
||||
|
||||
updated_host = user_input[CONF_HOST]
|
||||
|
||||
if self._context_entry.data.get(CONF_HOST) != updated_host:
|
||||
if reconfigure_entry.data.get(CONF_HOST) != updated_host:
|
||||
self._async_abort_entries_match({CONF_HOST: updated_host})
|
||||
|
||||
errors: dict[str, str] = {}
|
||||
|
@ -121,9 +119,7 @@ class ValloxConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
errors[CONF_HOST] = "unknown"
|
||||
else:
|
||||
return self.async_update_reload_and_abort(
|
||||
self._context_entry,
|
||||
data={**self._context_entry.data, CONF_HOST: updated_host},
|
||||
reason="reconfigure_successful",
|
||||
reconfigure_entry, data_updates={CONF_HOST: updated_host}
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
|
|
Loading…
Add table
Reference in a new issue