Skip to content

Commit

Permalink
Fix version merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
pvizeli committed Aug 8, 2017
2 parents f751b0e + c39d635 commit 261bda8
Show file tree
Hide file tree
Showing 22 changed files with 487 additions and 238 deletions.
38 changes: 26 additions & 12 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,27 @@ Return QR-Code
- POST `/host/reboot`
- GET `/host/info`

See HostControl info command.

```json
{
"type": "",
"version": "",
"last_version": "",
"features": ["shutdown", "reboot", "update", "network_info", "network_control"],
"features": ["shutdown", "reboot", "update", "hostname", "network_info", "network_control"],
"hostname": "",
"os": ""
"os": "",
"audio": {
"input": "0,0",
"output": "0,0"
}
}
```

- POST `/host/options`

```json
{
"audio_input": "0,0",
"audio_output": "0,0"
}
```

Expand Down Expand Up @@ -259,11 +270,6 @@ Optional:
```json
{
"hostname": "",
"mode": "dhcp|fixed",
"ssid": "",
"ip": "",
"netmask": "",
"gateway": ""
}
```

Expand Down Expand Up @@ -330,7 +336,9 @@ Get all available addons.
"privileged": ["NET_ADMIN", "SYS_ADMIN"],
"devices": ["/dev/xy"],
"url": "null|url",
"logo": "bool"
"logo": "bool",
"audio": "bool",
"hassio_api": "bool"
}
],
"repositories": [
Expand Down Expand Up @@ -367,7 +375,11 @@ Get all available addons.
"privileged": ["NET_ADMIN", "SYS_ADMIN"],
"devices": ["/dev/xy"],
"logo": "bool",
"webui": "null|http(s)://[HOST]:port/xy/zx"
"hassio_api": "bool",
"webui": "null|http(s)://[HOST]:port/xy/zx",
"audio": "bool",
"audio_input": "null|0,0",
"audio_output": "null|0,0"
}
```

Expand All @@ -383,10 +395,12 @@ Get all available addons.
"CONTAINER": "port|[ip, port]"
},
"options": {},
"audio_output": "null|0,0",
"audio_input": "null|0,0"
}
```

For reset custom network settings, set it `null`.
For reset custom network/audio settings, set it `null`.

- POST `/addons/{addon}/start`

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Hass.io

### First private cloud solution for home automation.

Hass.io is a Docker based system for managing your Home Assistant installation and related applications. The system is controlled via Home Assistant which communicates with the supervisor. The supervisor provides an API to manage the installation. This includes changing network settings or installing and updating software.

![](misc/hassio.png?raw=true)

[HassIO-Addons](https://github.com/home-assistant/hassio-addons) | [HassIO-Build](https://github.com/home-assistant/hassio-build)
- [Hass.io Addons](https://github.com/home-assistant/hassio-addons)
- [Hass.io Build](https://github.com/home-assistant/hassio-build)

## Installation

Expand Down
2 changes: 1 addition & 1 deletion hassio/addons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def _add_repository(url):

# don't add built-in repository to config
if url not in BUILTIN_REPOSITORIES:
self.config.addons_repositories = url
self.config.add_addon_repository(url)

tasks = [_add_repository(url) for url in new_rep - old_rep]
if tasks:
Expand Down
91 changes: 77 additions & 14 deletions hassio/addons/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
ATTR_URL, ATTR_ARCH, ATTR_LOCATON, ATTR_DEVICES, ATTR_ENVIRONMENT,
ATTR_HOST_NETWORK, ATTR_TMPFS, ATTR_PRIVILEGED, ATTR_STARTUP,
STATE_STARTED, STATE_STOPPED, STATE_NONE, ATTR_USER, ATTR_SYSTEM,
ATTR_STATE, ATTR_TIMEOUT, ATTR_AUTO_UPDATE, ATTR_NETWORK, ATTR_WEBUI)
ATTR_STATE, ATTR_TIMEOUT, ATTR_AUTO_UPDATE, ATTR_NETWORK, ATTR_WEBUI,
ATTR_HASSIO_API, ATTR_AUDIO, ATTR_AUDIO_OUTPUT, ATTR_AUDIO_INPUT)
from .util import check_installed
from ..dock.addon import DockerAddon
from ..tools import write_json_file, read_json_file
Expand Down Expand Up @@ -244,6 +245,56 @@ def privileged(self):
"""Return list of privilege."""
return self._mesh.get(ATTR_PRIVILEGED)

@property
def use_hassio_api(self):
"""Return True if the add-on access to hassio api."""
return self._mesh[ATTR_HASSIO_API]

@property
def with_audio(self):
"""Return True if the add-on access to audio."""
return self._mesh[ATTR_AUDIO]

@property
def audio_output(self):
"""Return ALSA config for output or None."""
if not self.with_audio:
return

setting = self.config.audio_output
if self.is_installed and ATTR_AUDIO_OUTPUT in self.data.user[self._id]:
setting = self.data.user[self._id][ATTR_AUDIO_OUTPUT]
return setting

@audio_output.setter
def audio_output(self, value):
"""Set/remove custom audio output settings."""
if value is None:
self.data.user[self._id].pop(ATTR_AUDIO_OUTPUT, None)
else:
self.data.user[self._id][ATTR_AUDIO_OUTPUT] = value
self.data.save()

@property
def audio_input(self):
"""Return ALSA config for input or None."""
if not self.with_audio:
return

setting = self.config.audio_input
if self.is_installed and ATTR_AUDIO_INPUT in self.data.user[self._id]:
setting = self.data.user[self._id][ATTR_AUDIO_INPUT]
return setting

@audio_input.setter
def audio_input(self, value):
"""Set/remove custom audio input settings."""
if value is None:
self.data.user[self._id].pop(ATTR_AUDIO_INPUT, None)
else:
self.data.user[self._id][ATTR_AUDIO_INPUT] = value
self.data.save()

@property
def url(self):
"""Return url of addon."""
Expand Down Expand Up @@ -413,14 +464,20 @@ async def state(self):
return STATE_STOPPED

@check_installed
async def start(self):
"""Set options and start addon."""
return await self.addon_docker.run()
def start(self):
"""Set options and start addon.
Return a coroutine.
"""
return self.addon_docker.run()

@check_installed
async def stop(self):
"""Stop addon."""
return await self.addon_docker.stop()
def stop(self):
"""Stop addon.
Return a coroutine.
"""
return self.addon_docker.stop()

@check_installed
async def update(self, version=None):
Expand All @@ -430,7 +487,7 @@ async def update(self, version=None):
if version == self.version_installed:
_LOGGER.warning(
"Addon %s is already installed in %s", self._id, version)
return True
return False

if not await self.addon_docker.update(version):
return False
Expand All @@ -439,14 +496,20 @@ async def update(self, version=None):
return True

@check_installed
async def restart(self):
"""Restart addon."""
return await self.addon_docker.restart()
def restart(self):
"""Restart addon.
Return a coroutine.
"""
return self.addon_docker.restart()

@check_installed
async def logs(self):
"""Return addons log output."""
return await self.addon_docker.logs()
def logs(self):
"""Return addons log output.
Return a coroutine.
"""
return self.addon_docker.logs()

@check_installed
async def snapshot(self, tar_file):
Expand Down
19 changes: 11 additions & 8 deletions hassio/addons/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
ARCH_AARCH64, ARCH_AMD64, ARCH_I386, ATTR_TMPFS, ATTR_PRIVILEGED,
ATTR_USER, ATTR_STATE, ATTR_SYSTEM, STATE_STARTED, STATE_STOPPED,
ATTR_LOCATON, ATTR_REPOSITORY, ATTR_TIMEOUT, ATTR_NETWORK,
ATTR_AUTO_UPDATE, ATTR_WEBUI)
from ..validate import NETWORK_PORT, DOCKER_PORTS
ATTR_AUTO_UPDATE, ATTR_WEBUI, ATTR_AUDIO, ATTR_AUDIO_INPUT,
ATTR_AUDIO_OUTPUT, ATTR_HASSIO_API)
from ..validate import NETWORK_PORT, DOCKER_PORTS, ALSA_CHANNEL


MAP_VOLUME = r"^(config|ssl|addons|backup|share)(?::(rw|:ro))?$"
Expand All @@ -38,14 +39,12 @@
PRIVILEGED_ALL = [
"NET_ADMIN",
"SYS_ADMIN",
"SYS_RAWIO"
]


def _migrate_startup(value):
"""Migrate startup schema.
REMOVE after 0.50-
"""
def _simple_startup(value):
"""Simple startup schema."""
if value == "before":
return STARTUP_SERVICES
if value == "after":
Expand All @@ -62,7 +61,7 @@ def _migrate_startup(value):
vol.Optional(ATTR_URL): vol.Url(),
vol.Optional(ATTR_ARCH, default=ARCH_ALL): [vol.In(ARCH_ALL)],
vol.Required(ATTR_STARTUP):
vol.All(_migrate_startup, vol.In(STARTUP_ALL)),
vol.All(_simple_startup, vol.In(STARTUP_ALL)),
vol.Required(ATTR_BOOT):
vol.In([BOOT_AUTO, BOOT_MANUAL]),
vol.Optional(ATTR_PORTS): DOCKER_PORTS,
Expand All @@ -75,6 +74,8 @@ def _migrate_startup(value):
vol.Optional(ATTR_MAP, default=[]): [vol.Match(MAP_VOLUME)],
vol.Optional(ATTR_ENVIRONMENT): {vol.Match(r"\w*"): vol.Coerce(str)},
vol.Optional(ATTR_PRIVILEGED): [vol.In(PRIVILEGED_ALL)],
vol.Optional(ATTR_AUDIO, default=False): vol.Boolean(),
vol.Optional(ATTR_HASSIO_API, default=False): vol.Boolean(),
vol.Required(ATTR_OPTIONS): dict,
vol.Required(ATTR_SCHEMA): vol.Any(vol.Schema({
vol.Coerce(str): vol.Any(ADDON_ELEMENT, [
Expand Down Expand Up @@ -103,6 +104,8 @@ def _migrate_startup(value):
vol.Optional(ATTR_BOOT):
vol.In([BOOT_AUTO, BOOT_MANUAL]),
vol.Optional(ATTR_NETWORK): DOCKER_PORTS,
vol.Optional(ATTR_AUDIO_OUTPUT): ALSA_CHANNEL,
vol.Optional(ATTR_AUDIO_INPUT): ALSA_CHANNEL,
})


Expand Down
5 changes: 3 additions & 2 deletions hassio/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def register_host(self, host_control, hardware):
self.webapp.router.add_post('/host/reboot', api_host.reboot)
self.webapp.router.add_post('/host/shutdown', api_host.shutdown)
self.webapp.router.add_post('/host/update', api_host.update)
self.webapp.router.add_post('/host/options', api_host.options)

def register_network(self, host_control):
"""Register network function."""
Expand All @@ -46,11 +47,11 @@ def register_network(self, host_control):
self.webapp.router.add_post('/network/options', api_net.options)

def register_supervisor(self, supervisor, snapshots, addons, host_control,
websession):
updater):
"""Register supervisor function."""
api_supervisor = APISupervisor(
self.config, self.loop, supervisor, snapshots, addons,
host_control, websession)
host_control, updater)

self.webapp.router.add_get('/supervisor/ping', api_supervisor.ping)
self.webapp.router.add_get('/supervisor/info', api_supervisor.info)
Expand Down
Loading

0 comments on commit 261bda8

Please sign in to comment.