diff --git a/homeassistant/components/brother/config_flow.py b/homeassistant/components/brother/config_flow.py index 8966b41c948..ffc2b3bfa8a 100644 --- a/homeassistant/components/brother/config_flow.py +++ b/homeassistant/components/brother/config_flow.py @@ -9,7 +9,7 @@ import voluptuous as vol from homeassistant.components import zeroconf from homeassistant.components.snmp import async_get_snmp_engine -from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult +from homeassistant.config_entries import ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_HOST, CONF_TYPE from homeassistant.core import HomeAssistant from homeassistant.exceptions import HomeAssistantError @@ -49,8 +49,6 @@ class BrotherConfigFlow(ConfigFlow, domain=DOMAIN): VERSION = 1 - entry: ConfigEntry - def __init__(self) -> None: """Initialize.""" self.brother: Brother @@ -145,18 +143,18 @@ class BrotherConfigFlow(ConfigFlow, domain=DOMAIN): self, user_input: dict[str, Any] | None = None ) -> ConfigFlowResult: """Handle a reconfiguration flow initialized by the user.""" - self.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 a reconfiguration flow initialized by the user.""" + entry = self._get_reconfigure_entry() errors = {} if user_input is not None: try: - await validate_input(self.hass, user_input, self.entry.unique_id) + await validate_input(self.hass, user_input, entry.unique_id) except InvalidHost: errors[CONF_HOST] = "wrong_host" except (ConnectionError, TimeoutError): @@ -166,20 +164,18 @@ class BrotherConfigFlow(ConfigFlow, domain=DOMAIN): except AnotherDevice: errors["base"] = "another_device" else: - self.hass.config_entries.async_update_entry( - self.entry, - data=self.entry.data | {CONF_HOST: user_input[CONF_HOST]}, + return self.async_update_reload_and_abort( + entry, + data_updates={CONF_HOST: user_input[CONF_HOST]}, ) - await self.hass.config_entries.async_reload(self.entry.entry_id) - return self.async_abort(reason="reconfigure_successful") return self.async_show_form( step_id="reconfigure_confirm", data_schema=self.add_suggested_values_to_schema( data_schema=RECONFIGURE_SCHEMA, - suggested_values=self.entry.data | (user_input or {}), + suggested_values=entry.data | (user_input or {}), ), - description_placeholders={"printer_name": self.entry.title}, + description_placeholders={"printer_name": entry.title}, errors=errors, )