Wait for config entry platforms in KNX (#77437)
parent
eab0ff5185
commit
441d7c0461
|
@ -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
|
||||
|
|
|
@ -55,16 +55,21 @@ class KNXTestKit:
|
|||
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 @@ class KNXTestKit:
|
|||
):
|
||||
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()
|
||||
|
||||
########################
|
||||
|
|
Loading…
Reference in New Issue