mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 06:17:07 +00:00
Allow ignored bthome devices to be set up from the user flow (#137105)
This commit is contained in:
parent
9c4940e915
commit
d3da3b3470
@ -132,7 +132,7 @@ class BTHomeConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
return self._async_get_or_create_entry()
|
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):
|
for discovery_info in async_discovered_service_info(self.hass, False):
|
||||||
address = discovery_info.address
|
address = discovery_info.address
|
||||||
if address in current_addresses or address in self._discovered_devices:
|
if address in current_addresses or address in self._discovered_devices:
|
||||||
|
@ -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"
|
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(
|
async def test_async_step_user_with_found_devices_encryption(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user