diff --git a/homeassistant/components/config/config_entries.py b/homeassistant/components/config/config_entries.py index 584255764a34b1..7da89617bf7525 100644 --- a/homeassistant/components/config/config_entries.py +++ b/homeassistant/components/config/config_entries.py @@ -1,4 +1,6 @@ """Http views to control the config manager.""" +from typing import Any, Dict, Optional + import aiohttp.web_exceptions import voluptuous as vol import voluptuous_serialize @@ -312,16 +314,12 @@ async def ignore_config_flow(hass, connection, msg): ) return - if "unique_id" not in flow["context"]: - connection.send_error( - msg["id"], "no_unique_id", "Specified flow has no unique ID." - ) - return + data: Optional[Dict[str, Any]] = None + if "unique_id" in flow["context"]: + data = {"unique_id": flow["context"]["unique_id"]} await hass.config_entries.flow.async_init( - flow["handler"], - context={"source": config_entries.SOURCE_IGNORE}, - data={"unique_id": flow["context"]["unique_id"]}, + flow["handler"], context={"source": config_entries.SOURCE_IGNORE}, data=data, ) connection.send_result(msg["id"]) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index d4f76d9bb3767a..492f592caddf17 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -886,9 +886,14 @@ def _async_in_progress(self) -> List[Dict]: if flw["handler"] == self.handler and flw["flow_id"] != self.flow_id ] - async def async_step_ignore(self, user_input: Dict[str, Any]) -> Dict[str, Any]: + async def async_step_ignore( + self, user_input: Optional[Dict[str, Any]] + ) -> Dict[str, Any]: """Ignore this config flow.""" - await self.async_set_unique_id(user_input["unique_id"], raise_on_progress=False) + if user_input is not None and "unique_id" in user_input: + await self.async_set_unique_id( + user_input["unique_id"], raise_on_progress=False + ) return self.async_create_entry(title="Ignored", data={}) async def async_step_unignore(self, user_input: Dict[str, Any]) -> Dict[str, Any]: