Merge pull request #35 from home-assistant/dev

Release 0.22
This commit is contained in:
Pascal Vizeli 2017-05-08 06:47:04 +02:00 committed by GitHub
commit bc6eb5cab4
8 changed files with 56 additions and 5 deletions

1
API.md
View File

@ -176,6 +176,7 @@ Output the raw docker log
- GET `/addons/{addon}/info`
```json
{
"url": "null|url of addon",
"version": "VERSION",
"last_version": "LAST_VERSION",
"state": "started|stopped",

3
MANIFEST.in Normal file
View File

@ -0,0 +1,3 @@
include LICENSE.md
graft hassio
recursive-exclude * *.py[co]

View File

@ -0,0 +1,14 @@
{
"local": {
"slug": "local",
"name": "Local Add-Ons",
"url": "https://home-assistant.io/hassio",
"maintainer": "By our self"
},
"core": {
"slug": "core",
"name": "Built-in Add-Ons",
"url": "https://home-assistant.io/addons",
"maintainer": "Home Assistant authors"
}
}

View File

@ -1,6 +1,7 @@
"""Init file for HassIO addons."""
import copy
import logging
import json
from pathlib import Path, PurePath
import voluptuous as vol
@ -13,7 +14,7 @@ from ..const import (
FILE_HASSIO_ADDONS, ATTR_NAME, ATTR_VERSION, ATTR_SLUG, ATTR_DESCRIPTON,
ATTR_STARTUP, ATTR_BOOT, ATTR_MAP, ATTR_OPTIONS, ATTR_PORTS, BOOT_AUTO,
DOCKER_REPO, ATTR_SCHEMA, ATTR_IMAGE, MAP_CONFIG, MAP_SSL, MAP_ADDONS,
MAP_BACKUP, ATTR_REPOSITORY)
MAP_BACKUP, ATTR_REPOSITORY, ATTR_URL)
from ..config import Config
from ..tools import read_json_file, write_json_file
@ -60,6 +61,9 @@ class AddonsData(Config):
self._read_addons_folder(
self.config.path_addons_local, REPOSITORY_LOCAL)
# add built-in repositories information
self._set_builtin_repositories()
# read custom git repositories
for repository_element in self.config.path_addons_git.iterdir():
if repository_element.is_dir():
@ -114,6 +118,29 @@ class AddonsData(Config):
_LOGGER.warning("Can't read %s -> %s", addon,
humanize_error(addon_config, ex))
def _set_builtin_repositories(self):
"""Add local built-in repository into dataset."""
try:
builtin_file = Path(__file__).parent.joinpath('built-in.json')
builtin_data = read_json_file(builtin_file)
except (OSError, json.JSONDecodeError) as err:
_LOGGER.warning("Can't read built-in.json -> %s", err)
return
# if core addons are available
for data in self._addons_cache.values():
if data[ATTR_REPOSITORY] == REPOSITORY_CORE:
self._repositories_data[REPOSITORY_CORE] = \
builtin_data[REPOSITORY_CORE]
break
# if local addons are available
for data in self._addons_cache.values():
if data[ATTR_REPOSITORY] == REPOSITORY_LOCAL:
self._repositories_data[REPOSITORY_LOCAL] = \
builtin_data[REPOSITORY_LOCAL]
break
def merge_update_config(self):
"""Update local config if they have update.
@ -259,6 +286,10 @@ class AddonsData(Config):
"""Return ports of addon."""
return self._system_data[addon].get(ATTR_PORTS)
def get_url(self, addon):
"""Return url of addon."""
return self._system_data[addon].get(ATTR_URL)
def get_image(self, addon):
"""Return image name of addon."""
addon_data = self._system_data.get(

View File

@ -30,6 +30,7 @@ SCHEMA_ADDON_CONFIG = vol.Schema({
vol.Optional(ATTR_MAP, default=[]): [
vol.In([MAP_CONFIG, MAP_SSL, MAP_ADDONS, MAP_BACKUP])
],
vol.Optional(ATTR_URL): vol.Url(),
vol.Required(ATTR_OPTIONS): dict,
vol.Required(ATTR_SCHEMA): {
vol.Coerce(str): vol.Any(ADDON_ELEMENT, [

View File

@ -8,7 +8,7 @@ from voluptuous.humanize import humanize_error
from .util import api_process, api_process_raw, api_validate
from ..const import (
ATTR_VERSION, ATTR_LAST_VERSION, ATTR_STATE, ATTR_BOOT, ATTR_OPTIONS,
STATE_STOPPED, STATE_STARTED, BOOT_AUTO, BOOT_MANUAL)
ATTR_URL, STATE_STOPPED, STATE_STARTED, BOOT_AUTO, BOOT_MANUAL)
_LOGGER = logging.getLogger(__name__)
@ -53,6 +53,7 @@ class APIAddons(object):
ATTR_STATE: await self.addons.state(addon),
ATTR_BOOT: self.addons.get_boot(addon),
ATTR_OPTIONS: self.addons.get_options(addon),
ATTR_URL: self.addons.get_url(addon),
}
@api_process

View File

@ -1,7 +1,7 @@
"""Const file for HassIO."""
from pathlib import Path
HASSIO_VERSION = '0.21'
HASSIO_VERSION = '0.22'
URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/'
'hassio/master/version.json')

View File

@ -1,6 +1,6 @@
{
"hassio": "0.21",
"homeassistant": "0.44",
"hassio": "0.22",
"homeassistant": "0.44.1",
"resinos": "0.7",
"resinhup": "0.1",
"generic": "0.3"