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
3 changes: 3 additions & 0 deletions homeassistant/components/elkm1/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ async def _async_handle_discovery(self) -> FlowResult:
for progress in self._async_in_progress():
if progress.get("context", {}).get(CONF_HOST) == host:
return self.async_abort(reason="already_in_progress")
# Handled ignored case since _async_current_entries
# is called with include_ignore=False
self._abort_if_unique_id_configured()
if not device.port:
if discovered_device := await async_discover_device(self.hass, host):
self._discovered_device = discovered_device
Expand Down
21 changes: 21 additions & 0 deletions tests/components/elkm1/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@
MODULE = "homeassistant.components.elkm1"


async def test_discovery_ignored_entry(hass):
"""Test we abort on ignored entry."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={CONF_HOST: f"elks://{MOCK_IP_ADDRESS}"},
unique_id="aa:bb:cc:dd:ee:ff",
source=config_entries.SOURCE_IGNORE,
)
config_entry.add_to_hass(hass)

with _patch_discovery(), _patch_elk():
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_INTEGRATION_DISCOVERY},
data=ELK_DISCOVERY_INFO,
)
await hass.async_block_till_done()
assert result["type"] == RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"


async def test_form_user_with_secure_elk_no_discovery(hass):
"""Test we can setup a secure elk."""

Expand Down