diff --git a/homeassistant/setup.py b/homeassistant/setup.py index 102c48e1d0741..331389da7c600 100644 --- a/homeassistant/setup.py +++ b/homeassistant/setup.py @@ -281,7 +281,7 @@ async def _async_setup_component( integration = await loader.async_get_integration(hass, domain) except loader.IntegrationNotFound: _log_error_setup_error(hass, domain, None, "Integration not found.") - if not hass.config.safe_mode: + if not hass.config.safe_mode and hass.config_entries.async_entries(domain): ir.async_create_issue( hass, HOMEASSISTANT_DOMAIN, diff --git a/tests/components/homeassistant/test_repairs.py b/tests/components/homeassistant/test_repairs.py index f81eaa694fac1..f84b29d8d2d8e 100644 --- a/tests/components/homeassistant/test_repairs.py +++ b/tests/components/homeassistant/test_repairs.py @@ -23,6 +23,7 @@ async def test_integration_not_found_confirm_step( await hass.async_block_till_done() assert await async_setup_component(hass, REPAIRS_DOMAIN, {REPAIRS_DOMAIN: {}}) await hass.async_block_till_done() + MockConfigEntry(domain="test1").add_to_hass(hass) assert await async_setup_component(hass, "test1", {}) is False await hass.async_block_till_done() entry1 = MockConfigEntry(domain="test1") @@ -83,6 +84,7 @@ async def test_integration_not_found_ignore_step( await hass.async_block_till_done() assert await async_setup_component(hass, REPAIRS_DOMAIN, {REPAIRS_DOMAIN: {}}) await hass.async_block_till_done() + MockConfigEntry(domain="test1").add_to_hass(hass) assert await async_setup_component(hass, "test1", {}) is False await hass.async_block_till_done() entry1 = MockConfigEntry(domain="test1") diff --git a/tests/test_setup.py b/tests/test_setup.py index c50f8392d6606..2d15c670cf7bd 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -248,22 +248,39 @@ async def test_component_not_found( hass: HomeAssistant, issue_registry: IssueRegistry ) -> None: """setup_component should raise a repair issue if component doesn't exist.""" + MockConfigEntry(domain="non_existing").add_to_hass(hass) assert await setup.async_setup_component(hass, "non_existing", {}) is False assert len(issue_registry.issues) == 1 - issue = issue_registry.async_get_issue( - HOMEASSISTANT_DOMAIN, "integration_not_found.non_existing" - ) - assert issue - assert issue.translation_key == "integration_not_found" + assert ( + HOMEASSISTANT_DOMAIN, + "integration_not_found.non_existing", + ) in issue_registry.issues + + +async def test_yaml_component_not_found( + hass: HomeAssistant, issue_registry: IssueRegistry +) -> None: + """setup_component should only raise an exception for missing config entry integrations.""" + assert await setup.async_setup_component(hass, "non_existing", {}) is False + assert len(issue_registry.issues) == 0 + assert ( + HOMEASSISTANT_DOMAIN, + "integration_not_found.non_existing", + ) not in issue_registry.issues async def test_component_missing_not_raising_in_safe_mode( hass: HomeAssistant, issue_registry: IssueRegistry ) -> None: """setup_component should not raise an issue if component doesn't exist in safe.""" + MockConfigEntry(domain="non_existing").add_to_hass(hass) hass.config.safe_mode = True assert await setup.async_setup_component(hass, "non_existing", {}) is False assert len(issue_registry.issues) == 0 + assert ( + HOMEASSISTANT_DOMAIN, + "integration_not_found.non_existing", + ) not in issue_registry.issues async def test_component_not_double_initialized(hass: HomeAssistant) -> None: