diff --git a/hassio/core.py b/hassio/core.py index beaec91ad..ae557ae60 100644 --- a/hassio/core.py +++ b/hassio/core.py @@ -121,6 +121,8 @@ class HassIO(CoreSysAttributes): ): with suppress(HomeAssistantError): await self.sys_homeassistant.start() + else: + _LOGGER.info("Skip start of Home Assistant") # start addon mark as application await self.sys_addons.boot(STARTUP_APPLICATION) diff --git a/hassio/homeassistant.py b/hassio/homeassistant.py index cbfd8f34f..463dcc4ff 100644 --- a/hassio/homeassistant.py +++ b/hassio/homeassistant.py @@ -330,10 +330,6 @@ class HomeAssistant(JsonConfig, CoreSysAttributes): async def _start(self) -> None: """Start Home Assistant Docker & wait.""" - if await self.instance.is_running(): - _LOGGER.warning("Home Assistant is already running!") - return - # Create new API token self._data[ATTR_ACCESS_TOKEN] = secrets.token_hex(56) self.save_data() @@ -347,18 +343,21 @@ class HomeAssistant(JsonConfig, CoreSysAttributes): @process_lock async def start(self) -> None: """Run Home Assistant docker.""" - try: - if await self.instance.is_running(): - await self.instance.restart() - elif await self.instance.is_initialize(): + if await self.instance.is_running(): + _LOGGER.warning("Home Assistant is already running!") + return + + # Instance/Container exists, simple start + if await self.instance.is_initialize(): + try: await self.instance.start() - else: - await self._start() - return + except DockerAPIError: + raise HomeAssistantError() from None await self._block_till_run() - except DockerAPIError: - raise HomeAssistantError() from None + # No Instance/Container found, extended start + else: + await self._start() @process_lock async def stop(self) -> None: diff --git a/hassio/snapshots/__init__.py b/hassio/snapshots/__init__.py index 9595df19e..42b14cf56 100644 --- a/hassio/snapshots/__init__.py +++ b/hassio/snapshots/__init__.py @@ -291,8 +291,8 @@ class SnapshotManager(CoreSysAttributes): await self.lock.acquire() async with snapshot: - # Stop Home-Assistant if they will be restored later - if homeassistant and FOLDER_HOMEASSISTANT in folders: + # Stop Home-Assistant for config restore + if FOLDER_HOMEASSISTANT in folders: await self.sys_homeassistant.stop() snapshot.restore_homeassistant()