Skip to content
Snippets Groups Projects
Unverified Commit 7667024a authored by J. Nick Koston's avatar J. Nick Koston Committed by GitHub
Browse files

Remove extra confirmation step in tplink authenticated discovery flow (#109016)

Remove extra confirmation step in tplink discovery flow

After discovery, and manually entering credentials, we would ask
the user if they still wanted to set up the device. Instead we
now set create the config entry as soon as they enter correct
credentials as its clear that they want to proceed.
parent 6de83042
No related branches found
No related tags found
No related merge requests found
......@@ -159,7 +159,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self._discovered_device = device
await set_credentials(self.hass, username, password)
self.hass.async_create_task(self._async_reload_requires_auth_entries())
return await self.async_step_discovery_confirm()
return self._async_create_entry_from_device(self._discovered_device)
placeholders = self._async_make_placeholders_from_discovery()
self.context["title_placeholders"] = placeholders
......
......@@ -141,18 +141,9 @@ async def test_discovery_auth(
},
)
assert result2["type"] == "form"
assert result2["step_id"] == "discovery_confirm"
assert not result2["errors"]
result3 = await hass.config_entries.flow.async_configure(
result2["flow_id"], user_input={}
)
await hass.async_block_till_done()
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["title"] == DEFAULT_ENTRY_TITLE
assert result3["data"] == CREATE_ENTRY_DATA_AUTH
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == DEFAULT_ENTRY_TITLE
assert result2["data"] == CREATE_ENTRY_DATA_AUTH
@pytest.mark.parametrize(
......@@ -213,17 +204,8 @@ async def test_discovery_auth_errors(
CONF_PASSWORD: "fake_password",
},
)
assert result3["type"] is FlowResultType.FORM
assert result3["step_id"] == "discovery_confirm"
await hass.async_block_till_done()
result4 = await hass.config_entries.flow.async_configure(
result3["flow_id"],
{},
)
assert result4["type"] is FlowResultType.CREATE_ENTRY
assert result4["data"] == CREATE_ENTRY_DATA_AUTH
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["data"] == CREATE_ENTRY_DATA_AUTH
async def test_discovery_new_credentials(
......@@ -325,15 +307,8 @@ async def test_discovery_new_credentials_invalid(
CONF_PASSWORD: "fake_password",
},
)
assert result3["type"] is FlowResultType.FORM
assert result3["step_id"] == "discovery_confirm"
result4 = await hass.config_entries.flow.async_configure(
result3["flow_id"],
{},
)
assert result4["type"] is FlowResultType.CREATE_ENTRY
assert result4["data"] == CREATE_ENTRY_DATA_AUTH
assert result3["type"] is FlowResultType.CREATE_ENTRY
assert result3["data"] == CREATE_ENTRY_DATA_AUTH
async def test_discovery_with_existing_device_present(hass: HomeAssistant) -> None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment