diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index fdcdb5d4fe2..31e404ad87a 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -352,8 +352,8 @@ def from_config_dict(config: Dict[str, Any], future.set_exception(exc) # run task - future = asyncio.Future() - asyncio.Task(_async_init_from_config_dict(future), loop=hass.loop) + future = asyncio.Future(loop=hass.loop) + hass.loop.create_task(_async_init_from_config_dict(future)) hass.loop.run_until_complete(future) return future.result() @@ -452,8 +452,8 @@ def from_config_file(config_path: str, future.set_exception(exc) # run task - future = asyncio.Future() - asyncio.Task(_async_init_from_config_file(future), loop=hass.loop) + future = asyncio.Future(loop=hass.loop) + hass.loop.create_task(_async_init_from_config_file(future)) hass.loop.run_until_complete(future) return future.result() diff --git a/tests/components/test_group.py b/tests/components/test_group.py index 9b6d96d898f..786fee16624 100644 --- a/tests/components/test_group.py +++ b/tests/components/test_group.py @@ -368,9 +368,11 @@ class TestComponentsGroup(unittest.TestCase): # Hide the group group.set_visibility(self.hass, group_entity_id, False) group_state = self.hass.states.get(group_entity_id) + self.hass.block_till_done() self.assertTrue(group_state.attributes.get(ATTR_HIDDEN)) # Show it again group.set_visibility(self.hass, group_entity_id, True) group_state = self.hass.states.get(group_entity_id) + self.hass.block_till_done() self.assertIsNone(group_state.attributes.get(ATTR_HIDDEN))