From 2bc08d1fccac71a6b230d8c3c7d874feb95a25a6 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 4 Sep 2023 13:19:10 -0500 Subject: [PATCH] Fix module check in _async_get_flow_handler (#99509) We should have been checking for the module in hass.data[DATA_COMPONENTS] and not hass.config.components as the check was ineffective if there were no existing integrations instances for the domain which is the case for discovery or when the integration is ignored --- homeassistant/config_entries.py | 4 +++- homeassistant/loader.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index a3b03407a14..02117c3ac5a 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -2055,7 +2055,9 @@ async def _async_get_flow_handler( """Get a flow handler for specified domain.""" # First check if there is a handler registered for the domain - if domain in hass.config.components and (handler := HANDLERS.get(domain)): + if loader.is_component_module_loaded(hass, f"{domain}.config_flow") and ( + handler := HANDLERS.get(domain) + ): return handler await _load_integration(hass, domain, hass_config) diff --git a/homeassistant/loader.py b/homeassistant/loader.py index 40161bd3be9..37e470c1178 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -1162,3 +1162,8 @@ def _lookup_path(hass: HomeAssistant) -> list[str]: if hass.config.safe_mode: return [PACKAGE_BUILTIN] return [PACKAGE_CUSTOM_COMPONENTS, PACKAGE_BUILTIN] + + +def is_component_module_loaded(hass: HomeAssistant, module: str) -> bool: + """Test if a component module is loaded.""" + return module in hass.data[DATA_COMPONENTS]