mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix Vizio host string for zeroconf discovery (#42738)
This commit is contained in:
parent
a4947ed32d
commit
098dead16d
@ -348,9 +348,11 @@ class VizioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
"""Handle zeroconf discovery."""
|
"""Handle zeroconf discovery."""
|
||||||
assert self.hass
|
assert self.hass
|
||||||
|
|
||||||
discovery_info[
|
# If host already has port, no need to add it again
|
||||||
CONF_HOST
|
if ":" not in discovery_info[CONF_HOST]:
|
||||||
] = f"{discovery_info[CONF_HOST]}:{discovery_info[CONF_PORT]}"
|
discovery_info[
|
||||||
|
CONF_HOST
|
||||||
|
] = f"{discovery_info[CONF_HOST]}:{discovery_info[CONF_PORT]}"
|
||||||
|
|
||||||
# Set default name to discovered device name by stripping zeroconf service
|
# Set default name to discovered device name by stripping zeroconf service
|
||||||
# (`type`) from `name`
|
# (`type`) from `name`
|
||||||
|
@ -27,6 +27,7 @@ from homeassistant.const import (
|
|||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_PIN,
|
CONF_PIN,
|
||||||
|
CONF_PORT,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.helpers.typing import HomeAssistantType
|
||||||
|
|
||||||
@ -777,6 +778,35 @@ async def test_zeroconf_flow_already_configured(
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_zeroconf_flow_with_port_in_host(
|
||||||
|
hass: HomeAssistantType,
|
||||||
|
vizio_connect: pytest.fixture,
|
||||||
|
vizio_bypass_setup: pytest.fixture,
|
||||||
|
vizio_guess_device_type: pytest.fixture,
|
||||||
|
) -> None:
|
||||||
|
"""Test entity is already configured during zeroconf setup when port is in host."""
|
||||||
|
entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN,
|
||||||
|
data=MOCK_SPEAKER_CONFIG,
|
||||||
|
options={CONF_VOLUME_STEP: VOLUME_STEP},
|
||||||
|
unique_id=UNIQUE_ID,
|
||||||
|
)
|
||||||
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
|
# Try rediscovering same device, this time with port already in host
|
||||||
|
discovery_info = MOCK_ZEROCONF_SERVICE_INFO.copy()
|
||||||
|
discovery_info[
|
||||||
|
CONF_HOST
|
||||||
|
] = f"{discovery_info[CONF_HOST]}:{discovery_info[CONF_PORT]}"
|
||||||
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN, context={"source": SOURCE_ZEROCONF}, data=discovery_info
|
||||||
|
)
|
||||||
|
|
||||||
|
# Flow should abort because device is already setup
|
||||||
|
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||||
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
async def test_zeroconf_dupe_fail(
|
async def test_zeroconf_dupe_fail(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistantType,
|
||||||
vizio_connect: pytest.fixture,
|
vizio_connect: pytest.fixture,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user