diff --git a/homeassistant/components/knx/__init__.py b/homeassistant/components/knx/__init__.py index 1910227a5a4d77..fa014335df97f5 100644 --- a/homeassistant/components/knx/__init__.py +++ b/homeassistant/components/knx/__init__.py @@ -247,7 +247,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: create_knx_exposure(hass, knx_module.xknx, expose_config) ) - hass.config_entries.async_setup_platforms( + await hass.config_entries.async_forward_entry_setups( entry, [ platform diff --git a/tests/components/knx/conftest.py b/tests/components/knx/conftest.py index e5cf18b0c3c691..23e04b672ba73c 100644 --- a/tests/components/knx/conftest.py +++ b/tests/components/knx/conftest.py @@ -55,16 +55,21 @@ def assert_state(self, entity_id: str, state: str, **attributes) -> None: async def setup_integration(self, config): """Create the KNX integration.""" - def disable_rate_limiter(): - """Disable rate limiter for tests.""" + async def patch_xknx_start(): + """Patch `xknx.start` for unittests.""" # after XKNX.__init__() to not overwrite it by the config entry again # before StateUpdater starts to avoid slow down of tests self.xknx.rate_limit = 0 + # set XknxConnectionState.CONNECTED to avoid `unavailable` entities at startup + # and start StateUpdater. This would be awaited on normal startup too. + await self.xknx.connection_manager.connection_state_changed( + XknxConnectionState.CONNECTED + ) def knx_ip_interface_mock(): """Create a xknx knx ip interface mock.""" mock = Mock() - mock.start = AsyncMock(side_effect=disable_rate_limiter) + mock.start = AsyncMock(side_effect=patch_xknx_start) mock.stop = AsyncMock() mock.send_telegram = AsyncMock(side_effect=self._outgoing_telegrams.put) return mock @@ -81,9 +86,6 @@ def fish_xknx(*args, **kwargs): ): self.mock_config_entry.add_to_hass(self.hass) await async_setup_component(self.hass, KNX_DOMAIN, {KNX_DOMAIN: config}) - await self.xknx.connection_manager.connection_state_changed( - XknxConnectionState.CONNECTED - ) await self.hass.async_block_till_done() ########################