Allow ignored bthome devices to be set up from the user flow (#137105)

This commit is contained in:
J. Nick Koston 2025-02-01 13:08:24 -06:00 committed by GitHub
parent 9c4940e915
commit d3da3b3470
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 1 deletions

View File

@ -132,7 +132,7 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN):
return self._async_get_or_create_entry()
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 address in current_addresses or address in self._discovered_devices:

View File

@ -213,6 +213,36 @@ async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
assert result2["result"].unique_id == "54:48:E6:8F:80:A5"
async def test_async_step_user_replaces_ignored(hass: HomeAssistant) -> None:
"""Test setup from service info cache replaces an ignored entry."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id="54:48:E6:8F:80:A5",
data={},
source=config_entries.SOURCE_IGNORE,
)
entry.add_to_hass(hass)
with patch(
"homeassistant.components.bthome.config_flow.async_discovered_service_info",
return_value=[PRST_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"
with patch("homeassistant.components.bthome.async_setup_entry", return_value=True):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
user_input={"address": "54:48:E6:8F:80:A5"},
)
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["title"] == "b-parasite 80A5"
assert result2["data"] == {}
assert result2["result"].unique_id == "54:48:E6:8F:80:A5"
async def test_async_step_user_with_found_devices_encryption(
hass: HomeAssistant,
) -> None: