Allow stop/start home-assistant & flow of startup (#182)

* Allow config boot

* Read boot settings

* Use internal boot time for detect reboot

* Check if Home-Assistant need to watch

* Make datetime string and parse_datetime

* Add api calls

* fix lint p1

* Use new datetime parser for sessions and make a real default boot time

* fix lint p2

* only start docker if they is running

* convert to int (timestamp)

* add boot flag
This commit is contained in:
Pascal Vizeli
2017-09-11 14:14:26 +02:00
committed by GitHub
parent a733886803
commit 5a80be9fd4
12 changed files with 171 additions and 14 deletions

View File

@@ -6,7 +6,7 @@ import re
from .const import (
FILE_HASSIO_HOMEASSISTANT, ATTR_DEVICES, ATTR_IMAGE, ATTR_LAST_VERSION,
ATTR_VERSION)
ATTR_VERSION, ATTR_BOOT)
from .dock.homeassistant import DockerHomeAssistant
from .tools import JsonConfig, convert_to_ascii
from .validate import SCHEMA_HASS_CONFIG
@@ -73,6 +73,17 @@ class HomeAssistant(JsonConfig):
self._data[ATTR_DEVICES] = value
self.save()
@property
def boot(self):
"""Return True if home-assistant boot is enabled."""
return self._data[ATTR_BOOT]
@boot.setter
def boot(self, value):
"""Set home-assistant boot options."""
self._data[ATTR_BOOT] = value
self.save()
def set_custom(self, image, version):
"""Set a custom image for homeassistant."""
# reset
@@ -119,6 +130,7 @@ class HomeAssistant(JsonConfig):
async def update(self, version=None):
"""Update HomeAssistant version."""
version = version or self.last_version
running = await self.docker.is_running()
if version == self.docker.version:
_LOGGER.warning("Version %s is already installed", version)
@@ -127,7 +139,8 @@ class HomeAssistant(JsonConfig):
try:
return await self.docker.update(version)
finally:
await self.docker.run()
if running:
await self.docker.run()
def run(self):
"""Run HomeAssistant docker.
@@ -164,6 +177,13 @@ class HomeAssistant(JsonConfig):
"""
return self.docker.is_running()
def is_initialize(self):
"""Return True if a docker container is exists.
Return a coroutine.
"""
return self.docker.is_initialize()
@property
def in_progress(self):
"""Return True if a task is in progress."""