Add name to ignored entries (#45051)
* Add name to ignored entries * Fix test
This commit is contained in:
parent
f312b87a3f
commit
e83ced6737
5 changed files with 16 additions and 8 deletions
|
@ -318,7 +318,9 @@ async def config_entry_update(hass, connection, msg):
|
||||||
|
|
||||||
@websocket_api.require_admin
|
@websocket_api.require_admin
|
||||||
@websocket_api.async_response
|
@websocket_api.async_response
|
||||||
@websocket_api.websocket_command({"type": "config_entries/ignore_flow", "flow_id": str})
|
@websocket_api.websocket_command(
|
||||||
|
{"type": "config_entries/ignore_flow", "flow_id": str, "title": str}
|
||||||
|
)
|
||||||
async def ignore_config_flow(hass, connection, msg):
|
async def ignore_config_flow(hass, connection, msg):
|
||||||
"""Ignore a config flow."""
|
"""Ignore a config flow."""
|
||||||
flow = next(
|
flow = next(
|
||||||
|
@ -345,7 +347,7 @@ async def ignore_config_flow(hass, connection, msg):
|
||||||
await hass.config_entries.flow.async_init(
|
await hass.config_entries.flow.async_init(
|
||||||
flow["handler"],
|
flow["handler"],
|
||||||
context={"source": config_entries.SOURCE_IGNORE},
|
context={"source": config_entries.SOURCE_IGNORE},
|
||||||
data={"unique_id": flow["context"]["unique_id"]},
|
data={"unique_id": flow["context"]["unique_id"], "title": msg["title"]},
|
||||||
)
|
)
|
||||||
connection.send_result(msg["id"])
|
connection.send_result(msg["id"])
|
||||||
|
|
||||||
|
|
|
@ -975,7 +975,7 @@ class ConfigFlow(data_entry_flow.FlowHandler):
|
||||||
async def async_step_ignore(self, user_input: Dict[str, Any]) -> Dict[str, Any]:
|
async def async_step_ignore(self, user_input: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
"""Ignore this config flow."""
|
"""Ignore this config flow."""
|
||||||
await self.async_set_unique_id(user_input["unique_id"], raise_on_progress=False)
|
await self.async_set_unique_id(user_input["unique_id"], raise_on_progress=False)
|
||||||
return self.async_create_entry(title="Ignored", data={})
|
return self.async_create_entry(title=user_input["title"], data={})
|
||||||
|
|
||||||
async def async_step_unignore(self, user_input: Dict[str, Any]) -> Dict[str, Any]:
|
async def async_step_unignore(self, user_input: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
"""Rediscover a config entry by it's unique_id."""
|
"""Rediscover a config entry by it's unique_id."""
|
||||||
|
|
|
@ -750,6 +750,7 @@ async def test_ignore_flow(hass, hass_ws_client):
|
||||||
"id": 5,
|
"id": 5,
|
||||||
"type": "config_entries/ignore_flow",
|
"type": "config_entries/ignore_flow",
|
||||||
"flow_id": result["flow_id"],
|
"flow_id": result["flow_id"],
|
||||||
|
"title": "Test Integration",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
response = await ws_client.receive_json()
|
response = await ws_client.receive_json()
|
||||||
|
@ -761,3 +762,4 @@ async def test_ignore_flow(hass, hass_ws_client):
|
||||||
entry = hass.config_entries.async_entries("test")[0]
|
entry = hass.config_entries.async_entries("test")[0]
|
||||||
assert entry.source == "ignore"
|
assert entry.source == "ignore"
|
||||||
assert entry.unique_id == "mock-unique-id"
|
assert entry.unique_id == "mock-unique-id"
|
||||||
|
assert entry.title == "Test Integration"
|
||||||
|
|
|
@ -220,7 +220,7 @@ async def test_ignored_discoveries(hass, discovery_flow_conf):
|
||||||
await hass.config_entries.flow.async_init(
|
await hass.config_entries.flow.async_init(
|
||||||
flow["handler"],
|
flow["handler"],
|
||||||
context={"source": config_entries.SOURCE_IGNORE},
|
context={"source": config_entries.SOURCE_IGNORE},
|
||||||
data={"unique_id": flow["context"]["unique_id"]},
|
data={"unique_id": flow["context"]["unique_id"], "title": "Ignored Entry"},
|
||||||
)
|
)
|
||||||
|
|
||||||
# Second discovery should be aborted
|
# Second discovery should be aborted
|
||||||
|
|
|
@ -1523,7 +1523,7 @@ async def test_unique_id_ignore(hass, manager):
|
||||||
result2 = await manager.flow.async_init(
|
result2 = await manager.flow.async_init(
|
||||||
"comp",
|
"comp",
|
||||||
context={"source": config_entries.SOURCE_IGNORE},
|
context={"source": config_entries.SOURCE_IGNORE},
|
||||||
data={"unique_id": "mock-unique-id"},
|
data={"unique_id": "mock-unique-id", "title": "Ignored Title"},
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
|
@ -1537,6 +1537,7 @@ async def test_unique_id_ignore(hass, manager):
|
||||||
|
|
||||||
assert entry.source == "ignore"
|
assert entry.source == "ignore"
|
||||||
assert entry.unique_id == "mock-unique-id"
|
assert entry.unique_id == "mock-unique-id"
|
||||||
|
assert entry.title == "Ignored Title"
|
||||||
|
|
||||||
|
|
||||||
async def test_manual_add_overrides_ignored_entry(hass, manager):
|
async def test_manual_add_overrides_ignored_entry(hass, manager):
|
||||||
|
@ -1605,7 +1606,7 @@ async def test_unignore_step_form(hass, manager):
|
||||||
result = await manager.flow.async_init(
|
result = await manager.flow.async_init(
|
||||||
"comp",
|
"comp",
|
||||||
context={"source": config_entries.SOURCE_IGNORE},
|
context={"source": config_entries.SOURCE_IGNORE},
|
||||||
data={"unique_id": "mock-unique-id"},
|
data={"unique_id": "mock-unique-id", "title": "Ignored Title"},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
|
|
||||||
|
@ -1613,6 +1614,7 @@ async def test_unignore_step_form(hass, manager):
|
||||||
assert entry.source == "ignore"
|
assert entry.source == "ignore"
|
||||||
assert entry.unique_id == "mock-unique-id"
|
assert entry.unique_id == "mock-unique-id"
|
||||||
assert entry.domain == "comp"
|
assert entry.domain == "comp"
|
||||||
|
assert entry.title == "Ignored Title"
|
||||||
|
|
||||||
await manager.async_remove(entry.entry_id)
|
await manager.async_remove(entry.entry_id)
|
||||||
|
|
||||||
|
@ -1649,7 +1651,7 @@ async def test_unignore_create_entry(hass, manager):
|
||||||
result = await manager.flow.async_init(
|
result = await manager.flow.async_init(
|
||||||
"comp",
|
"comp",
|
||||||
context={"source": config_entries.SOURCE_IGNORE},
|
context={"source": config_entries.SOURCE_IGNORE},
|
||||||
data={"unique_id": "mock-unique-id"},
|
data={"unique_id": "mock-unique-id", "title": "Ignored Title"},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
|
|
||||||
|
@ -1657,6 +1659,7 @@ async def test_unignore_create_entry(hass, manager):
|
||||||
assert entry.source == "ignore"
|
assert entry.source == "ignore"
|
||||||
assert entry.unique_id == "mock-unique-id"
|
assert entry.unique_id == "mock-unique-id"
|
||||||
assert entry.domain == "comp"
|
assert entry.domain == "comp"
|
||||||
|
assert entry.title == "Ignored Title"
|
||||||
|
|
||||||
await manager.async_remove(entry.entry_id)
|
await manager.async_remove(entry.entry_id)
|
||||||
|
|
||||||
|
@ -1690,7 +1693,7 @@ async def test_unignore_default_impl(hass, manager):
|
||||||
result = await manager.flow.async_init(
|
result = await manager.flow.async_init(
|
||||||
"comp",
|
"comp",
|
||||||
context={"source": config_entries.SOURCE_IGNORE},
|
context={"source": config_entries.SOURCE_IGNORE},
|
||||||
data={"unique_id": "mock-unique-id"},
|
data={"unique_id": "mock-unique-id", "title": "Ignored Title"},
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
|
|
||||||
|
@ -1698,6 +1701,7 @@ async def test_unignore_default_impl(hass, manager):
|
||||||
assert entry.source == "ignore"
|
assert entry.source == "ignore"
|
||||||
assert entry.unique_id == "mock-unique-id"
|
assert entry.unique_id == "mock-unique-id"
|
||||||
assert entry.domain == "comp"
|
assert entry.domain == "comp"
|
||||||
|
assert entry.title == "Ignored Title"
|
||||||
|
|
||||||
await manager.async_remove(entry.entry_id)
|
await manager.async_remove(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
Loading…
Add table
Reference in a new issue