mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-23 00:56:29 +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):
|
with suppress(HomeAssistantError):
|
||||||
await self.sys_homeassistant.start()
|
await self.sys_homeassistant.start()
|
||||||
|
else:
|
||||||
|
_LOGGER.info("Skip start of Home Assistant")
|
||||||
|
|
||||||
# start addon mark as application
|
# start addon mark as application
|
||||||
await self.sys_addons.boot(STARTUP_APPLICATION)
|
await self.sys_addons.boot(STARTUP_APPLICATION)
|
||||||
|
@ -330,10 +330,6 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
|
|||||||
|
|
||||||
async def _start(self) -> None:
|
async def _start(self) -> None:
|
||||||
"""Start Home Assistant Docker & wait."""
|
"""Start Home Assistant Docker & wait."""
|
||||||
if await self.instance.is_running():
|
|
||||||
_LOGGER.warning("Home Assistant is already running!")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Create new API token
|
# Create new API token
|
||||||
self._data[ATTR_ACCESS_TOKEN] = secrets.token_hex(56)
|
self._data[ATTR_ACCESS_TOKEN] = secrets.token_hex(56)
|
||||||
self.save_data()
|
self.save_data()
|
||||||
@ -347,18 +343,21 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
|
|||||||
@process_lock
|
@process_lock
|
||||||
async def start(self) -> None:
|
async def start(self) -> None:
|
||||||
"""Run Home Assistant docker."""
|
"""Run Home Assistant docker."""
|
||||||
try:
|
if await self.instance.is_running():
|
||||||
if await self.instance.is_running():
|
_LOGGER.warning("Home Assistant is already running!")
|
||||||
await self.instance.restart()
|
return
|
||||||
elif await self.instance.is_initialize():
|
|
||||||
|
# Instance/Container exists, simple start
|
||||||
|
if await self.instance.is_initialize():
|
||||||
|
try:
|
||||||
await self.instance.start()
|
await self.instance.start()
|
||||||
else:
|
except DockerAPIError:
|
||||||
await self._start()
|
raise HomeAssistantError() from None
|
||||||
return
|
|
||||||
|
|
||||||
await self._block_till_run()
|
await self._block_till_run()
|
||||||
except DockerAPIError:
|
# No Instance/Container found, extended start
|
||||||
raise HomeAssistantError() from None
|
else:
|
||||||
|
await self._start()
|
||||||
|
|
||||||
@process_lock
|
@process_lock
|
||||||
async def stop(self) -> None:
|
async def stop(self) -> None:
|
||||||
|
@ -291,8 +291,8 @@ class SnapshotManager(CoreSysAttributes):
|
|||||||
await self.lock.acquire()
|
await self.lock.acquire()
|
||||||
|
|
||||||
async with snapshot:
|
async with snapshot:
|
||||||
# Stop Home-Assistant if they will be restored later
|
# Stop Home-Assistant for config restore
|
||||||
if homeassistant and FOLDER_HOMEASSISTANT in folders:
|
if FOLDER_HOMEASSISTANT in folders:
|
||||||
await self.sys_homeassistant.stop()
|
await self.sys_homeassistant.stop()
|
||||||
snapshot.restore_homeassistant()
|
snapshot.restore_homeassistant()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user