mirror of
https://github.com/home-assistant/core.git
synced 2026-04-29 10:23:46 +02:00
Allow ignored bluemaestro devices to be set up from the user flow (#155613)
This commit is contained in:
@@ -77,7 +77,7 @@ class EufyLifeConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
data={CONF_MODEL: model},
|
||||
)
|
||||
|
||||
current_addresses = self._async_current_ids()
|
||||
current_addresses = self._async_current_ids(include_ignore=False)
|
||||
for discovery_info in async_discovered_service_info(self.hass, False):
|
||||
address = discovery_info.address
|
||||
if (
|
||||
|
||||
@@ -4,6 +4,7 @@ from unittest.mock import patch
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.eufylife_ble.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_IGNORE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.data_entry_flow import FlowResultType
|
||||
|
||||
@@ -203,3 +204,40 @@ async def test_async_step_user_takes_precedence_over_discovery(
|
||||
|
||||
# Verify the original one was aborted
|
||||
assert not hass.config_entries.flow.async_progress(DOMAIN)
|
||||
|
||||
|
||||
async def test_user_setup_replaces_ignored_device(hass: HomeAssistant) -> None:
|
||||
"""Test the user initiated form can replace an ignored device."""
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id="11:22:33:44:55:66",
|
||||
source=SOURCE_IGNORE,
|
||||
data={},
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.eufylife_ble.config_flow.async_discovered_service_info",
|
||||
return_value=[T9146_SERVICE_INFO],
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_USER},
|
||||
)
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
# Verify the ignored device is in the dropdown
|
||||
assert "11:22:33:44:55:66" in result["data_schema"].schema["address"].container
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.eufylife_ble.async_setup_entry", return_value=True
|
||||
):
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={"address": "11:22:33:44:55:66"},
|
||||
)
|
||||
assert result2["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result2["title"] == "Smart Scale C1"
|
||||
assert result2["data"] == {"model": "eufy T9146"}
|
||||
assert result2["result"].unique_id == "11:22:33:44:55:66"
|
||||
|
||||
Reference in New Issue
Block a user