diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 14900153ae4..a8b2752d2aa 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -90,7 +90,7 @@ class ConfigEntryState(Enum): """The config entry has not been loaded""" FAILED_UNLOAD = "failed_unload", False """An error occurred when trying to unload the entry""" - SETUP_IN_PROGRESS = "setup_in_progress", True + SETUP_IN_PROGRESS = "setup_in_progress", False """The config entry is setting up.""" _recoverable: bool @@ -104,7 +104,11 @@ class ConfigEntryState(Enum): @property def recoverable(self) -> bool: - """Get if the state is recoverable.""" + """Get if the state is recoverable. + + If the entry is state is recoverable, unloads + and reloads are allowed. + """ return self._recoverable diff --git a/tests/test_config_entries.py b/tests/test_config_entries.py index dbbf542d36c..9372a906f71 100644 --- a/tests/test_config_entries.py +++ b/tests/test_config_entries.py @@ -3260,3 +3260,15 @@ async def test_unique_id_update_while_setup_in_progress( assert len(async_reload.mock_calls) == 0 await hass.async_block_till_done() assert entry.state is config_entries.ConfigEntryState.LOADED + + +async def test_disallow_entry_reload_with_setup_in_progresss(hass, manager): + """Test we do not allow reload while the config entry is still setting up.""" + entry = MockConfigEntry( + domain="comp", state=config_entries.ConfigEntryState.SETUP_IN_PROGRESS + ) + entry.add_to_hass(hass) + + with pytest.raises(config_entries.OperationNotAllowed): + assert await manager.async_reload(entry.entry_id) + assert entry.state is config_entries.ConfigEntryState.SETUP_IN_PROGRESS