Skip to content

Commit 7fa3597

Browse files
authored
Use new reauth helpers in vicare (#128779)
1 parent 2bc642a commit 7fa3597

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

homeassistant/components/vicare/config_flow.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import voluptuous as vol
1414

1515
from homeassistant.components import dhcp
16-
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
16+
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
1717
from homeassistant.const import CONF_CLIENT_ID, CONF_PASSWORD, CONF_USERNAME
1818
import homeassistant.helpers.config_validation as cv
1919
from homeassistant.helpers.device_registry import format_mac
@@ -50,7 +50,6 @@ class ViCareConfigFlow(ConfigFlow, domain=DOMAIN):
5050
"""Handle a config flow for ViCare."""
5151

5252
VERSION = 1
53-
entry: ConfigEntry | None
5453

5554
async def async_step_user(
5655
self, user_input: dict[str, Any] | None = None
@@ -81,19 +80,18 @@ async def async_step_reauth(
8180
self, entry_data: Mapping[str, Any]
8281
) -> ConfigFlowResult:
8382
"""Handle re-authentication with ViCare."""
84-
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
8583
return await self.async_step_reauth_confirm()
8684

8785
async def async_step_reauth_confirm(
8886
self, user_input: dict[str, Any] | None = None
8987
) -> ConfigFlowResult:
9088
"""Confirm re-authentication with ViCare."""
9189
errors: dict[str, str] = {}
92-
assert self.entry is not None
9390

91+
reauth_entry = self._get_reauth_entry()
9492
if user_input:
9593
data = {
96-
**self.entry.data,
94+
**reauth_entry.data,
9795
**user_input,
9896
}
9997

@@ -102,17 +100,12 @@ async def async_step_reauth_confirm(
102100
except (PyViCareInvalidConfigurationError, PyViCareInvalidCredentialsError):
103101
errors["base"] = "invalid_auth"
104102
else:
105-
self.hass.config_entries.async_update_entry(
106-
self.entry,
107-
data=data,
108-
)
109-
await self.hass.config_entries.async_reload(self.entry.entry_id)
110-
return self.async_abort(reason="reauth_successful")
103+
return self.async_update_reload_and_abort(reauth_entry, data=data)
111104

112105
return self.async_show_form(
113106
step_id="reauth_confirm",
114107
data_schema=self.add_suggested_values_to_schema(
115-
REAUTH_SCHEMA, self.entry.data
108+
REAUTH_SCHEMA, reauth_entry.data
116109
),
117110
errors=errors,
118111
)

0 commit comments

Comments
 (0)