mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-12-24 20:35:55 +00:00
Cleanup config / new updater object / New audio (#135)
* Cleanup config / new updater object / New audio * Cleanup beta_channel * fix lint * fix lint p3 * Fix lint p4 * Allow set audio options * Fix errors * add host options
This commit is contained in:
@@ -7,7 +7,8 @@ import voluptuous as vol
|
||||
from .util import api_process_hostcontrol, api_process, api_validate
|
||||
from ..const import (
|
||||
ATTR_VERSION, ATTR_LAST_VERSION, ATTR_TYPE, ATTR_HOSTNAME, ATTR_FEATURES,
|
||||
ATTR_OS, ATTR_SERIAL, ATTR_INPUT, ATTR_DISK, ATTR_AUDIO)
|
||||
ATTR_OS, ATTR_SERIAL, ATTR_INPUT, ATTR_DISK, ATTR_AUDIO, ATTR_OUTPUT)
|
||||
from ..validate import ALSA_CHANNEL
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -15,6 +16,13 @@ SCHEMA_VERSION = vol.Schema({
|
||||
vol.Optional(ATTR_VERSION): vol.Coerce(str),
|
||||
})
|
||||
|
||||
SCHEMA_OPTIONS = vol.Schema({
|
||||
vol.Optional(ATTR_AUDIO): vol.Schema({
|
||||
vol.Optional(ATTR_OUTPUT): ALSA_CHANNEL,
|
||||
vol.Optional(ATTR_INPUT): ALSA_CHANNEL,
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
class APIHost(object):
|
||||
"""Handle rest api for host functions."""
|
||||
@@ -38,6 +46,19 @@ class APIHost(object):
|
||||
ATTR_OS: self.host_control.os_info,
|
||||
}
|
||||
|
||||
@api_process
|
||||
async def options(self, request):
|
||||
"""Process host options."""
|
||||
body = await api_validate(SCHEMA_OPTIONS, request)
|
||||
|
||||
if ATTR_AUDIO in body:
|
||||
if ATTR_OUTPUT in body[ATTR_AUDIO]:
|
||||
self.config.audio_output = body[ATTR_AUDIO][ATTR_OUTPUT]
|
||||
if ATTR_INPUT in body[ATTR_AUDIO]:
|
||||
self.config.audio_input = body[ATTR_AUDIO][ATTR_INPUT]
|
||||
|
||||
return True
|
||||
|
||||
@api_process_hostcontrol
|
||||
def reboot(self, request):
|
||||
"""Reboot host.
|
||||
|
||||
Reference in New Issue
Block a user