diff --git a/homeassistant/components/permobil/config_flow.py b/homeassistant/components/permobil/config_flow.py index f7f247a412e..07ddefa9dce 100644 --- a/homeassistant/components/permobil/config_flow.py +++ b/homeassistant/components/permobil/config_flow.py @@ -14,7 +14,7 @@ from mypermobil import ( ) import voluptuous as vol -from homeassistant.config_entries import ConfigFlow, ConfigFlowResult +from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult from homeassistant.const import CONF_CODE, CONF_EMAIL, CONF_REGION, CONF_TOKEN, CONF_TTL from homeassistant.core import HomeAssistant, async_get_hass from homeassistant.helpers import selector @@ -158,6 +158,11 @@ class PermobilConfigFlow(ConfigFlow, domain=DOMAIN): description_placeholders={"app_name": "MyPermobil"}, ) + if self.source == SOURCE_REAUTH: + return self.async_update_reload_and_abort( + self._get_reauth_entry(), title=self.data[CONF_EMAIL], data=self.data + ) + return self.async_create_entry(title=self.data[CONF_EMAIL], data=self.data) async def async_step_reauth( diff --git a/homeassistant/components/permobil/strings.json b/homeassistant/components/permobil/strings.json index d3a9290854e..cbce8d5d86f 100644 --- a/homeassistant/components/permobil/strings.json +++ b/homeassistant/components/permobil/strings.json @@ -20,7 +20,8 @@ } }, "abort": { - "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" + "already_configured": "[%key:common::config_flow::abort::already_configured_device%]", + "reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]" }, "error": { "unknown": "Unexpected error, more information in the logs", diff --git a/tests/components/permobil/test_config_flow.py b/tests/components/permobil/test_config_flow.py index 4474340f811..f9121f8f268 100644 --- a/tests/components/permobil/test_config_flow.py +++ b/tests/components/permobil/test_config_flow.py @@ -294,14 +294,15 @@ async def test_config_flow_reauth_success( assert result["step_id"] == "email_code" assert result["errors"] == {} - # request request new token + # request new token result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={CONF_CODE: reauth_code}, ) - assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["data"] == { + assert result["type"] is FlowResultType.ABORT + assert result["reason"] == "reauth_successful" + assert mock_entry.data == { CONF_EMAIL: MOCK_EMAIL, CONF_REGION: MOCK_URL, CONF_CODE: reauth_code,