mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-10-21 17:49:28 +00:00
Leverage access and refresh tokens if available (#575)
* Leverage access and refresh tokens if available * Update homeassistant.py * Update homeassistant.py * Update proxy.py * Migrate HomeAssistant to new exception layout * Fix build for 3.7 * Cleanups * Fix style * fix log strings * Fix new style * Fix travis build * python 3.7 * next try * fix * fix lint * Fix lint p2 * Add logging * Fix logging * fix access * Fix spell * fix return * Fix runtime * Add to hass config
This commit is contained in:

committed by
Pascal Vizeli

parent
1b481e0b37
commit
4df42e054d
@@ -10,7 +10,7 @@ from ..const import (
|
||||
ATTR_PORT, ATTR_PASSWORD, ATTR_SSL, ATTR_WATCHDOG, ATTR_CPU_PERCENT,
|
||||
ATTR_MEMORY_USAGE, ATTR_MEMORY_LIMIT, ATTR_NETWORK_RX, ATTR_NETWORK_TX,
|
||||
ATTR_BLK_READ, ATTR_BLK_WRITE, ATTR_WAIT_BOOT, ATTR_MACHINE,
|
||||
CONTENT_TYPE_BINARY)
|
||||
ATTR_REFRESH_TOKEN, CONTENT_TYPE_BINARY)
|
||||
from ..coresys import CoreSysAttributes
|
||||
from ..validate import NETWORK_PORT, DOCKER_IMAGE
|
||||
|
||||
@@ -30,6 +30,8 @@ SCHEMA_OPTIONS = vol.Schema({
|
||||
vol.Optional(ATTR_WATCHDOG): vol.Boolean(),
|
||||
vol.Optional(ATTR_WAIT_BOOT):
|
||||
vol.All(vol.Coerce(int), vol.Range(min=60)),
|
||||
# Required once we enforce user system
|
||||
vol.Optional(ATTR_REFRESH_TOKEN): str,
|
||||
})
|
||||
|
||||
SCHEMA_VERSION = vol.Schema({
|
||||
@@ -83,8 +85,10 @@ class APIHomeAssistant(CoreSysAttributes):
|
||||
if ATTR_WAIT_BOOT in body:
|
||||
self.sys_homeassistant.wait_boot = body[ATTR_WAIT_BOOT]
|
||||
|
||||
if ATTR_REFRESH_TOKEN in body:
|
||||
self.sys_homeassistant.refresh_token = body[ATTR_REFRESH_TOKEN]
|
||||
|
||||
self.sys_homeassistant.save_data()
|
||||
return True
|
||||
|
||||
@api_process
|
||||
async def stats(self, request):
|
||||
@@ -109,11 +113,7 @@ class APIHomeAssistant(CoreSysAttributes):
|
||||
body = await api_validate(SCHEMA_VERSION, request)
|
||||
version = body.get(ATTR_VERSION, self.sys_homeassistant.last_version)
|
||||
|
||||
if version == self.sys_homeassistant.version:
|
||||
raise RuntimeError("Version {} is already in use".format(version))
|
||||
|
||||
return await asyncio.shield(
|
||||
self.sys_homeassistant.update(version))
|
||||
await asyncio.shield(self.sys_homeassistant.update(version))
|
||||
|
||||
@api_process
|
||||
def stop(self, request):
|
||||
@@ -123,7 +123,7 @@ class APIHomeAssistant(CoreSysAttributes):
|
||||
@api_process
|
||||
def start(self, request):
|
||||
"""Start homeassistant."""
|
||||
return asyncio.shield(self.sys_homeassistant.start())
|
||||
asyncio.shield(self.sys_homeassistant.start())
|
||||
|
||||
@api_process
|
||||
def restart(self, request):
|
||||
|
Reference in New Issue
Block a user