Skip to content

Commit a287499

Browse files
authored
Allow ignored rapt_ble devices to be set up from the user flow (home-assistant#154606)
1 parent 3fe37d6 commit a287499

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

homeassistant/components/rapt_ble/config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async def async_step_user(
7272
title=self._discovered_devices[address], data={}
7373
)
7474

75-
current_addresses = self._async_current_ids()
75+
current_addresses = self._async_current_ids(include_ignore=False)
7676
for discovery_info in async_discovered_service_info(self.hass, False):
7777
address = discovery_info.address
7878
if address in current_addresses or address in self._discovered_devices:

tests/components/rapt_ble/test_config_flow.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,38 @@ async def test_async_step_user_no_devices_found(hass: HomeAssistant) -> None:
5454
assert result["reason"] == "no_devices_found"
5555

5656

57+
async def test_async_step_user_replaces_ignored(hass: HomeAssistant) -> None:
58+
"""Test setup from service info cache replaces an ignored entry."""
59+
entry = MockConfigEntry(
60+
domain=DOMAIN,
61+
unique_id=RAPT_MAC,
62+
data={},
63+
source=config_entries.SOURCE_IGNORE,
64+
)
65+
entry.add_to_hass(hass)
66+
with patch(
67+
"homeassistant.components.rapt_ble.config_flow.async_discovered_service_info",
68+
return_value=[COMPLETE_SERVICE_INFO],
69+
):
70+
result = await hass.config_entries.flow.async_init(
71+
DOMAIN,
72+
context={"source": config_entries.SOURCE_USER},
73+
)
74+
assert result["type"] is FlowResultType.FORM
75+
assert result["step_id"] == "user"
76+
with patch(
77+
"homeassistant.components.rapt_ble.async_setup_entry", return_value=True
78+
):
79+
result2 = await hass.config_entries.flow.async_configure(
80+
result["flow_id"],
81+
user_input={"address": RAPT_MAC},
82+
)
83+
assert result2["type"] is FlowResultType.CREATE_ENTRY
84+
assert result2["title"] == "RAPT Pill 0666"
85+
assert result2["data"] == {}
86+
assert result2["result"].unique_id == RAPT_MAC
87+
88+
5789
async def test_async_step_user_with_found_devices(hass: HomeAssistant) -> None:
5890
"""Test setup from service info cache with devices found."""
5991
with patch(

0 commit comments

Comments
 (0)