diff --git a/homeassistant/helpers/integration_platform.py b/homeassistant/helpers/integration_platform.py index fb9f7808e28..d6d44eb6858 100644 --- a/homeassistant/helpers/integration_platform.py +++ b/homeassistant/helpers/integration_platform.py @@ -69,6 +69,9 @@ async def async_process_integration_platform( that the integration platforms are loaded before the entities are created. """ + if DATA_INTEGRATION_PLATFORMS not in hass.data: + # There are no integraton platforms loaded yet + return integration_platforms: list[IntegrationPlatform] = hass.data[ DATA_INTEGRATION_PLATFORMS ] diff --git a/tests/helpers/test_integration_platform.py b/tests/helpers/test_integration_platform.py index 9bd5932e54e..b2105f30706 100644 --- a/tests/helpers/test_integration_platform.py +++ b/tests/helpers/test_integration_platform.py @@ -1,6 +1,9 @@ """Test integration platform helpers.""" from unittest.mock import Mock +from homeassistant.helpers.integration_platform import ( + async_process_integration_platform, +) from homeassistant.setup import ATTR_COMPONENT, EVENT_COMPONENT_LOADED from tests.common import mock_platform @@ -41,3 +44,10 @@ async def test_process_integration_platforms(hass): hass, "event" ) assert len(processed) == 2 + + +async def test_process_integration_platforms_none_loaded(hass): + """Test processing integrations with none loaded.""" + # Verify we can call async_process_integration_platform + # when there are none loaded and it does not throw + await async_process_integration_platform(hass, "any")