Store keenetic_ndms2 flow data in flow handler attributes (#127174)

pull/126761/head^2
Erik Montnemery 2024-10-01 11:16:40 +02:00 committed by GitHub
parent d9bba25f67
commit f71baf3c73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 3 deletions

View File

@ -47,6 +47,8 @@ class KeeneticFlowHandler(ConfigFlow, domain=DOMAIN):
VERSION = 1 VERSION = 1
host: str | bytes | None = None
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow( def async_get_options_flow(
@ -61,7 +63,7 @@ class KeeneticFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle a flow initialized by the user.""" """Handle a flow initialized by the user."""
errors = {} errors = {}
if user_input is not None: if user_input is not None:
host = self.context.get(CONF_HOST) or user_input[CONF_HOST] host = self.host or user_input[CONF_HOST]
self._async_abort_entries_match({CONF_HOST: host}) self._async_abort_entries_match({CONF_HOST: host})
_client = Client( _client = Client(
@ -86,7 +88,7 @@ class KeeneticFlowHandler(ConfigFlow, domain=DOMAIN):
) )
host_schema: VolDictType = ( host_schema: VolDictType = (
{vol.Required(CONF_HOST): str} if CONF_HOST not in self.context else {} {vol.Required(CONF_HOST): str} if not self.host else {}
) )
return self.async_show_form( return self.async_show_form(
@ -122,7 +124,7 @@ class KeeneticFlowHandler(ConfigFlow, domain=DOMAIN):
self._async_abort_entries_match({CONF_HOST: host}) self._async_abort_entries_match({CONF_HOST: host})
self.context[CONF_HOST] = host self.host = host
self.context["title_placeholders"] = { self.context["title_placeholders"] = {
"name": friendly_name, "name": friendly_name,
"host": host, "host": host,