Fix HEOS user initiated setup when discovery is waiting confirmation (#140119)

This commit is contained in:
Andrew Sayre 2025-03-08 07:57:44 -06:00 committed by Franck Nijhof
parent fd2dee3c11
commit 323bc54efc
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
2 changed files with 30 additions and 1 deletions

View File

@ -205,7 +205,7 @@ class HeosFlowHandler(ConfigFlow, domain=DOMAIN):
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Obtain host and validate connection."""
await self.async_set_unique_id(DOMAIN)
await self.async_set_unique_id(DOMAIN, raise_on_progress=False)
self._abort_if_unique_id_configured(error="single_instance_allowed")
# Try connecting to host if provided
errors: dict[str, str] = {}

View File

@ -88,6 +88,35 @@ async def test_create_entry_when_host_valid(
assert controller.disconnect.call_count == 1
async def test_manual_setup_with_discovery_in_progress(
hass: HomeAssistant,
discovery_data: SsdpServiceInfo,
controller: MockHeos,
system: HeosSystem,
) -> None:
"""Test user can manually set up when discovery is in progress."""
# Single discovered, selects preferred host, shows confirm
controller.get_system_info.return_value = system
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_SSDP}, data=discovery_data
)
assert result["type"] is FlowResultType.FORM
assert result["step_id"] == "confirm_discovery"
# Setup manually
user_result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}
)
assert user_result["type"] is FlowResultType.FORM
user_result = await hass.config_entries.flow.async_configure(
user_result["flow_id"], user_input={CONF_HOST: "127.0.0.1"}
)
assert user_result["type"] is FlowResultType.CREATE_ENTRY
# Discovery flow is removed
assert not hass.config_entries.flow.async_progress_by_handler(DOMAIN)
async def test_discovery(
hass: HomeAssistant,
discovery_data: SsdpServiceInfo,