Use new reauth helpers in tessie (#128760)

This commit is contained in:
epenet 2024-10-19 22:04:52 +02:00 committed by GitHub
parent eaa4a43458
commit 98732cb033
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,7 +14,6 @@ from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_ACCESS_TOKEN
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from . import TessieConfigEntry
from .const import DOMAIN
TESSIE_SCHEMA = vol.Schema({vol.Required(CONF_ACCESS_TOKEN): str})
@ -29,10 +28,6 @@ class TessieConfigFlow(ConfigFlow, domain=DOMAIN):
VERSION = 1
def __init__(self) -> None:
"""Initialize."""
self._reauth_entry: TessieConfigEntry | None = None
async def async_step_user(
self, user_input: Mapping[str, Any] | None = None
) -> ConfigFlowResult:
@ -70,9 +65,6 @@ class TessieConfigFlow(ConfigFlow, domain=DOMAIN):
self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult:
"""Handle re-auth."""
self._reauth_entry = self.hass.config_entries.async_get_entry(
self.context["entry_id"]
)
return await self.async_step_reauth_confirm()
async def async_step_reauth_confirm(
@ -80,7 +72,7 @@ class TessieConfigFlow(ConfigFlow, domain=DOMAIN):
) -> ConfigFlowResult:
"""Get update API Key from the user."""
errors: dict[str, str] = {}
assert self._reauth_entry
if user_input:
try:
await get_state_of_all_vehicles(
@ -96,7 +88,7 @@ class TessieConfigFlow(ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
else:
return self.async_update_reload_and_abort(
self._reauth_entry, data=user_input
self._get_reauth_entry(), data=user_input
)
return self.async_show_form(