mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Wait for config entry platforms in KNX (#77437)
This commit is contained in:
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)
|
create_knx_exposure(hass, knx_module.xknx, expose_config)
|
||||||
)
|
)
|
||||||
|
|
||||||
hass.config_entries.async_setup_platforms(
|
await hass.config_entries.async_forward_entry_setups(
|
||||||
entry,
|
entry,
|
||||||
[
|
[
|
||||||
platform
|
platform
|
||||||
|
@ -55,16 +55,21 @@ class KNXTestKit:
|
|||||||
async def setup_integration(self, config):
|
async def setup_integration(self, config):
|
||||||
"""Create the KNX integration."""
|
"""Create the KNX integration."""
|
||||||
|
|
||||||
def disable_rate_limiter():
|
async def patch_xknx_start():
|
||||||
"""Disable rate limiter for tests."""
|
"""Patch `xknx.start` for unittests."""
|
||||||
# after XKNX.__init__() to not overwrite it by the config entry again
|
# after XKNX.__init__() to not overwrite it by the config entry again
|
||||||
# before StateUpdater starts to avoid slow down of tests
|
# before StateUpdater starts to avoid slow down of tests
|
||||||
self.xknx.rate_limit = 0
|
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():
|
def knx_ip_interface_mock():
|
||||||
"""Create a xknx knx ip interface mock."""
|
"""Create a xknx knx ip interface mock."""
|
||||||
mock = Mock()
|
mock = Mock()
|
||||||
mock.start = AsyncMock(side_effect=disable_rate_limiter)
|
mock.start = AsyncMock(side_effect=patch_xknx_start)
|
||||||
mock.stop = AsyncMock()
|
mock.stop = AsyncMock()
|
||||||
mock.send_telegram = AsyncMock(side_effect=self._outgoing_telegrams.put)
|
mock.send_telegram = AsyncMock(side_effect=self._outgoing_telegrams.put)
|
||||||
return mock
|
return mock
|
||||||
@ -81,9 +86,6 @@ class KNXTestKit:
|
|||||||
):
|
):
|
||||||
self.mock_config_entry.add_to_hass(self.hass)
|
self.mock_config_entry.add_to_hass(self.hass)
|
||||||
await async_setup_component(self.hass, KNX_DOMAIN, {KNX_DOMAIN: config})
|
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()
|
await self.hass.async_block_till_done()
|
||||||
|
|
||||||
########################
|
########################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user