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.
This commit is contained in:
J. Nick Koston 2024-01-28 09:23:07 -10:00 committed by GitHub
parent 6de8304256
commit 7667024a2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 33 deletions

View file

@ -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

View file

@ -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: