Abort vizio zeroconf config flow if unique ID is already configured (#34313)
parent
de440cf579
commit
059df5e3e2
|
@ -341,6 +341,7 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
await self.async_set_unique_id(
|
await self.async_set_unique_id(
|
||||||
unique_id=discovery_info[CONF_HOST].split(":")[0], raise_on_progress=True
|
unique_id=discovery_info[CONF_HOST].split(":")[0], raise_on_progress=True
|
||||||
)
|
)
|
||||||
|
self._abort_if_unique_id_configured()
|
||||||
|
|
||||||
discovery_info[
|
discovery_info[
|
||||||
CONF_HOST
|
CONF_HOST
|
||||||
|
|
|
@ -174,6 +174,7 @@ MOCK_INCLUDE_APPS = {
|
||||||
CONF_INCLUDE_OR_EXCLUDE: CONF_INCLUDE.title(),
|
CONF_INCLUDE_OR_EXCLUDE: CONF_INCLUDE.title(),
|
||||||
CONF_APPS_TO_INCLUDE_OR_EXCLUDE: [CURRENT_APP],
|
CONF_APPS_TO_INCLUDE_OR_EXCLUDE: [CURRENT_APP],
|
||||||
}
|
}
|
||||||
|
|
||||||
MOCK_INCLUDE_NO_APPS = {
|
MOCK_INCLUDE_NO_APPS = {
|
||||||
CONF_INCLUDE_OR_EXCLUDE: CONF_INCLUDE.title(),
|
CONF_INCLUDE_OR_EXCLUDE: CONF_INCLUDE.title(),
|
||||||
CONF_APPS_TO_INCLUDE_OR_EXCLUDE: [],
|
CONF_APPS_TO_INCLUDE_OR_EXCLUDE: [],
|
||||||
|
|
|
@ -51,6 +51,7 @@ from .const import (
|
||||||
NAME2,
|
NAME2,
|
||||||
UNIQUE_ID,
|
UNIQUE_ID,
|
||||||
VOLUME_STEP,
|
VOLUME_STEP,
|
||||||
|
ZEROCONF_HOST,
|
||||||
)
|
)
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
@ -827,3 +828,28 @@ async def test_zeroconf_ignore(
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||||
|
|
||||||
|
|
||||||
|
async def test_zeroconf_abort_when_ignored(
|
||||||
|
hass: HomeAssistantType,
|
||||||
|
vizio_connect: pytest.fixture,
|
||||||
|
vizio_bypass_setup: pytest.fixture,
|
||||||
|
vizio_guess_device_type: pytest.fixture,
|
||||||
|
) -> None:
|
||||||
|
"""Test zeroconf discovery aborts when the same host has been ignored."""
|
||||||
|
entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN,
|
||||||
|
data=MOCK_SPEAKER_CONFIG,
|
||||||
|
options={CONF_VOLUME_STEP: VOLUME_STEP},
|
||||||
|
source=SOURCE_IGNORE,
|
||||||
|
unique_id=ZEROCONF_HOST,
|
||||||
|
)
|
||||||
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
|
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"] == "already_configured"
|
||||||
|
|
Loading…
Reference in New Issue