Skip to content

Commit 51c6c1b

Browse files
authored
Allow ignored Onkyo devices to be set up from the user flow (home-assistant#150921)
1 parent c4fce1c commit 51c6c1b

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

homeassistant/components/onkyo/config_flow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ async def async_step_eiscp_discovery(
168168

169169
self._discovered_infos = {}
170170
discovered_names = {}
171-
current_unique_ids = self._async_current_ids()
171+
current_unique_ids = self._async_current_ids(include_ignore=False)
172172
for info in infos:
173173
if info.identifier in current_unique_ids:
174174
continue

tests/components/onkyo/test_config_flow.py

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
OPTION_MAX_VOLUME_DEFAULT,
1515
OPTION_VOLUME_RESOLUTION,
1616
)
17-
from homeassistant.config_entries import SOURCE_USER
17+
from homeassistant.config_entries import SOURCE_IGNORE, SOURCE_USER
1818
from homeassistant.const import CONF_HOST
1919
from homeassistant.core import HomeAssistant
2020
from homeassistant.data_entry_flow import FlowResultType
@@ -240,6 +240,57 @@ async def test_eiscp_discovery_error(
240240
assert result["reason"] == error_reason
241241

242242

243+
async def test_eiscp_discovery_replace_ignored_entry(
244+
hass: HomeAssistant, mock_config_entry: MockConfigEntry
245+
) -> None:
246+
"""Test eiscp discovery can replace an ignored config entry."""
247+
mock_config_entry.source = SOURCE_IGNORE
248+
await setup_integration(hass, mock_config_entry)
249+
250+
result = await hass.config_entries.flow.async_init(
251+
DOMAIN, context={"source": SOURCE_USER}
252+
)
253+
254+
assert result["type"] is FlowResultType.MENU
255+
assert result["step_id"] == "user"
256+
257+
result = await hass.config_entries.flow.async_configure(
258+
result["flow_id"], {"next_step_id": "eiscp_discovery"}
259+
)
260+
261+
assert result["type"] is FlowResultType.FORM
262+
assert result["step_id"] == "eiscp_discovery"
263+
264+
devices = result["data_schema"].schema["device"].container
265+
assert devices == {
266+
RECEIVER_INFO.identifier: _receiver_display_name(RECEIVER_INFO),
267+
RECEIVER_INFO_2.identifier: _receiver_display_name(RECEIVER_INFO_2),
268+
}
269+
270+
result = await hass.config_entries.flow.async_configure(
271+
result["flow_id"], user_input={"device": RECEIVER_INFO.identifier}
272+
)
273+
274+
assert result["type"] is FlowResultType.FORM
275+
assert result["step_id"] == "configure_receiver"
276+
277+
result = await hass.config_entries.flow.async_configure(
278+
result["flow_id"],
279+
user_input={
280+
OPTION_VOLUME_RESOLUTION: 200,
281+
OPTION_INPUT_SOURCES: ["TV"],
282+
OPTION_LISTENING_MODES: ["THX"],
283+
},
284+
)
285+
286+
assert result["type"] is FlowResultType.CREATE_ENTRY
287+
assert result["data"][CONF_HOST] == RECEIVER_INFO.host
288+
assert result["result"].unique_id == RECEIVER_INFO.identifier
289+
assert result["title"] == RECEIVER_INFO.model_name
290+
291+
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
292+
293+
243294
@pytest.mark.usefixtures("mock_setup_entry")
244295
async def test_ssdp_discovery(
245296
hass: HomeAssistant, mock_config_entry: MockConfigEntry

0 commit comments

Comments
 (0)