mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Do not cache reconfigure entry in vallox config flow (#128029)
This commit is contained in:
parent
577ae6923a
commit
c8178ab915
@ -8,7 +8,7 @@ from typing import Any
|
|||||||
from vallox_websocket_api import Vallox, ValloxApiException
|
from vallox_websocket_api import Vallox, ValloxApiException
|
||||||
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_HOST, CONF_NAME
|
from homeassistant.const import CONF_HOST, CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
@ -40,8 +40,6 @@ class ValloxConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
_context_entry: ConfigEntry
|
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
@ -88,24 +86,24 @@ class ValloxConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle reconfiguration of the Vallox device host address."""
|
"""Handle reconfiguration of the Vallox device host address."""
|
||||||
self._context_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 reconfiguration of the Vallox device host address."""
|
"""Handle reconfiguration of the Vallox device host address."""
|
||||||
|
reconfigure_entry = self._get_reconfigure_entry()
|
||||||
if not user_input:
|
if not user_input:
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="reconfigure_confirm",
|
step_id="reconfigure_confirm",
|
||||||
data_schema=self.add_suggested_values_to_schema(
|
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]
|
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})
|
self._async_abort_entries_match({CONF_HOST: updated_host})
|
||||||
|
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
@ -121,9 +119,7 @@ class ValloxConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
errors[CONF_HOST] = "unknown"
|
errors[CONF_HOST] = "unknown"
|
||||||
else:
|
else:
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(
|
||||||
self._context_entry,
|
reconfigure_entry, data_updates={CONF_HOST: updated_host}
|
||||||
data={**self._context_entry.data, CONF_HOST: updated_host},
|
|
||||||
reason="reconfigure_successful",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user