mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-20 23:56:30 +00:00
Home Assistant Core start flow / partial restore (#1507)
* Fix start flow logic * Add a note * Fix flow on partial restore
This commit is contained in:
parent
c33d31996d
commit
9e5c276e3b
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user