mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-08-14 11:39:21 +00:00

* Add HassOS OTA support on Hass.io * Update dt.py * Update updater.py * add rauc dbus / initial dbus signal handling * Update gdbus.py * Update hassos.py * Update const.py * Update hassos.py * Update exceptions.py * Update hassos.py * Update rauc.py * Update rauc.py * Update rauc.py * Update hassos.py * Update hassos.py * Update hassos.py * Update hassos.py * Update hassos.py * Update hassos.py * Update hassos.py * Update __init__.py * Update hassos.py * Update hassos.py * Update updater.py * Update updater.py * Update exceptions.py * Update exceptions.py * Update hassos.py * Update dt.py * fix lint * Fix update * fix property * tmp disabled * fix path * fix rauc * info * More details * cleanup signal hadnling * fix * Fix lint
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
"""Init file for Hass.io hassos rest api."""
|
|
import asyncio
|
|
import logging
|
|
|
|
import voluptuous as vol
|
|
|
|
from .utils import api_process, api_validate
|
|
from ..const import ATTR_VERSION, ATTR_BOARD, ATTR_VERSION_LATEST
|
|
from ..coresys import CoreSysAttributes
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
SCHEMA_VERSION = vol.Schema({
|
|
vol.Optional(ATTR_VERSION): vol.Coerce(str),
|
|
})
|
|
|
|
|
|
class APIHassOS(CoreSysAttributes):
|
|
"""Handle rest api for hassos functions."""
|
|
|
|
@api_process
|
|
async def info(self, request):
|
|
"""Return hassos information."""
|
|
return {
|
|
ATTR_VERSION: self.sys_hassos.version,
|
|
ATTR_VERSION_LATEST: self.sys_hassos.version_latest,
|
|
ATTR_BOARD: self.sys_hassos.board,
|
|
}
|
|
|
|
@api_process
|
|
async def update(self, request):
|
|
"""Update HassOS."""
|
|
body = await api_validate(SCHEMA_VERSION, request)
|
|
version = body.get(ATTR_VERSION, self.sys_hassos.version_latest)
|
|
|
|
await asyncio.shield(self.sys_hassos.update(version))
|
|
|
|
@api_process
|
|
def config_sync(self, request):
|
|
"""Trigger config reload on HassOS."""
|
|
return asyncio.shield(self.sys_hassos.config_sync())
|