Abort vizio discovery flow without unique ID (#43303)
* abort vizio discovery flow if unique ID cant be found because it means we cant connect * add tests * fix abort callpull/43356/head
parent
0e155f5240
commit
27707d9711
|
@ -369,6 +369,10 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
discovery_info[CONF_DEVICE_CLASS],
|
||||
session=async_get_clientsession(self.hass, False),
|
||||
)
|
||||
|
||||
if not unique_id:
|
||||
return self.async_abort(reason="cannot_connect")
|
||||
|
||||
await self.async_set_unique_id(unique_id=unique_id, raise_on_progress=True)
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
},
|
||||
"abort": {
|
||||
"already_configured_device": "[%key:common::config_flow::abort::already_configured_device%]",
|
||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||
"updated_entry": "This entry has already been setup but the name, apps, and/or options defined in the configuration do not match the previously imported configuration, so the configuration entry has been updated accordingly."
|
||||
}
|
||||
},
|
||||
|
|
|
@ -856,6 +856,21 @@ async def test_zeroconf_ignore(
|
|||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
|
||||
|
||||
async def test_zeroconf_no_unique_id(
|
||||
hass: HomeAssistantType,
|
||||
vizio_no_unique_id: pytest.fixture,
|
||||
) -> None:
|
||||
"""Test zeroconf discovery aborts when unique_id is None."""
|
||||
|
||||
discovery_info = MOCK_ZEROCONF_SERVICE_INFO.copy()
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||
)
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_zeroconf_abort_when_ignored(
|
||||
hass: HomeAssistantType,
|
||||
vizio_connect: pytest.fixture,
|
||||
|
|
Loading…
Reference in New Issue