mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Use new reauth helpers in smlight (#128744)
This commit is contained in:
parent
a9ec5f5c38
commit
42613dbcf8
@ -15,7 +15,6 @@ from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_USERNA
|
|||||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||||
from homeassistant.helpers.device_registry import format_mac
|
from homeassistant.helpers.device_registry import format_mac
|
||||||
|
|
||||||
from . import SmConfigEntry
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
STEP_USER_DATA_SCHEMA = vol.Schema(
|
STEP_USER_DATA_SCHEMA = vol.Schema(
|
||||||
@ -39,7 +38,6 @@ class SmlightConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Initialize the config flow."""
|
"""Initialize the config flow."""
|
||||||
self.client: Api2
|
self.client: Api2
|
||||||
self.host: str | None = None
|
self.host: str | None = None
|
||||||
self._reauth_entry: SmConfigEntry | None = None
|
|
||||||
|
|
||||||
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
|
||||||
@ -140,9 +138,6 @@ class SmlightConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle reauth when API Authentication failed."""
|
"""Handle reauth when API Authentication failed."""
|
||||||
|
|
||||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
|
||||||
self.context["entry_id"]
|
|
||||||
)
|
|
||||||
host = entry_data[CONF_HOST]
|
host = entry_data[CONF_HOST]
|
||||||
self.client = Api2(host, session=async_get_clientsession(self.hass))
|
self.client = Api2(host, session=async_get_clientsession(self.hass))
|
||||||
self.host = host
|
self.host = host
|
||||||
@ -164,11 +159,8 @@ class SmlightConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
except SmlightConnectionError:
|
except SmlightConnectionError:
|
||||||
return self.async_abort(reason="cannot_connect")
|
return self.async_abort(reason="cannot_connect")
|
||||||
else:
|
else:
|
||||||
assert self._reauth_entry is not None
|
|
||||||
|
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(
|
||||||
self._reauth_entry,
|
self._get_reauth_entry(), data_updates=user_input
|
||||||
data={**self._reauth_entry.data, **user_input},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user