Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions homeassistant/components/vizio/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ async def async_step_zeroconf(
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()

Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/vizio/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
},
Expand Down
15 changes: 15 additions & 0 deletions tests/components/vizio/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,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,
Expand Down