mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-28 03:26:32 +00:00
commit
bc6eb5cab4
1
API.md
1
API.md
@ -176,6 +176,7 @@ Output the raw docker log
|
|||||||
- GET `/addons/{addon}/info`
|
- GET `/addons/{addon}/info`
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
"url": "null|url of addon",
|
||||||
"version": "VERSION",
|
"version": "VERSION",
|
||||||
"last_version": "LAST_VERSION",
|
"last_version": "LAST_VERSION",
|
||||||
"state": "started|stopped",
|
"state": "started|stopped",
|
||||||
|
3
MANIFEST.in
Normal file
3
MANIFEST.in
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
include LICENSE.md
|
||||||
|
graft hassio
|
||||||
|
recursive-exclude * *.py[co]
|
14
hassio/addons/built-in.json
Normal file
14
hassio/addons/built-in.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
"""Init file for HassIO addons."""
|
"""Init file for HassIO addons."""
|
||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
|
import json
|
||||||
from pathlib import Path, PurePath
|
from pathlib import Path, PurePath
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@ -13,7 +14,7 @@ from ..const import (
|
|||||||
FILE_HASSIO_ADDONS, ATTR_NAME, ATTR_VERSION, ATTR_SLUG, ATTR_DESCRIPTON,
|
FILE_HASSIO_ADDONS, ATTR_NAME, ATTR_VERSION, ATTR_SLUG, ATTR_DESCRIPTON,
|
||||||
ATTR_STARTUP, ATTR_BOOT, ATTR_MAP, ATTR_OPTIONS, ATTR_PORTS, BOOT_AUTO,
|
ATTR_STARTUP, ATTR_BOOT, ATTR_MAP, ATTR_OPTIONS, ATTR_PORTS, BOOT_AUTO,
|
||||||
DOCKER_REPO, ATTR_SCHEMA, ATTR_IMAGE, MAP_CONFIG, MAP_SSL, MAP_ADDONS,
|
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 ..config import Config
|
||||||
from ..tools import read_json_file, write_json_file
|
from ..tools import read_json_file, write_json_file
|
||||||
|
|
||||||
@ -60,6 +61,9 @@ class AddonsData(Config):
|
|||||||
self._read_addons_folder(
|
self._read_addons_folder(
|
||||||
self.config.path_addons_local, REPOSITORY_LOCAL)
|
self.config.path_addons_local, REPOSITORY_LOCAL)
|
||||||
|
|
||||||
|
# add built-in repositories information
|
||||||
|
self._set_builtin_repositories()
|
||||||
|
|
||||||
# read custom git repositories
|
# read custom git repositories
|
||||||
for repository_element in self.config.path_addons_git.iterdir():
|
for repository_element in self.config.path_addons_git.iterdir():
|
||||||
if repository_element.is_dir():
|
if repository_element.is_dir():
|
||||||
@ -114,6 +118,29 @@ class AddonsData(Config):
|
|||||||
_LOGGER.warning("Can't read %s -> %s", addon,
|
_LOGGER.warning("Can't read %s -> %s", addon,
|
||||||
humanize_error(addon_config, ex))
|
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):
|
def merge_update_config(self):
|
||||||
"""Update local config if they have update.
|
"""Update local config if they have update.
|
||||||
|
|
||||||
@ -259,6 +286,10 @@ class AddonsData(Config):
|
|||||||
"""Return ports of addon."""
|
"""Return ports of addon."""
|
||||||
return self._system_data[addon].get(ATTR_PORTS)
|
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):
|
def get_image(self, addon):
|
||||||
"""Return image name of addon."""
|
"""Return image name of addon."""
|
||||||
addon_data = self._system_data.get(
|
addon_data = self._system_data.get(
|
||||||
|
@ -30,6 +30,7 @@ SCHEMA_ADDON_CONFIG = vol.Schema({
|
|||||||
vol.Optional(ATTR_MAP, default=[]): [
|
vol.Optional(ATTR_MAP, default=[]): [
|
||||||
vol.In([MAP_CONFIG, MAP_SSL, MAP_ADDONS, MAP_BACKUP])
|
vol.In([MAP_CONFIG, MAP_SSL, MAP_ADDONS, MAP_BACKUP])
|
||||||
],
|
],
|
||||||
|
vol.Optional(ATTR_URL): vol.Url(),
|
||||||
vol.Required(ATTR_OPTIONS): dict,
|
vol.Required(ATTR_OPTIONS): dict,
|
||||||
vol.Required(ATTR_SCHEMA): {
|
vol.Required(ATTR_SCHEMA): {
|
||||||
vol.Coerce(str): vol.Any(ADDON_ELEMENT, [
|
vol.Coerce(str): vol.Any(ADDON_ELEMENT, [
|
||||||
|
@ -8,7 +8,7 @@ from voluptuous.humanize import humanize_error
|
|||||||
from .util import api_process, api_process_raw, api_validate
|
from .util import api_process, api_process_raw, api_validate
|
||||||
from ..const import (
|
from ..const import (
|
||||||
ATTR_VERSION, ATTR_LAST_VERSION, ATTR_STATE, ATTR_BOOT, ATTR_OPTIONS,
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -53,6 +53,7 @@ class APIAddons(object):
|
|||||||
ATTR_STATE: await self.addons.state(addon),
|
ATTR_STATE: await self.addons.state(addon),
|
||||||
ATTR_BOOT: self.addons.get_boot(addon),
|
ATTR_BOOT: self.addons.get_boot(addon),
|
||||||
ATTR_OPTIONS: self.addons.get_options(addon),
|
ATTR_OPTIONS: self.addons.get_options(addon),
|
||||||
|
ATTR_URL: self.addons.get_url(addon),
|
||||||
}
|
}
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""Const file for HassIO."""
|
"""Const file for HassIO."""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
HASSIO_VERSION = '0.21'
|
HASSIO_VERSION = '0.22'
|
||||||
|
|
||||||
URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/'
|
URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/'
|
||||||
'hassio/master/version.json')
|
'hassio/master/version.json')
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"hassio": "0.21",
|
"hassio": "0.22",
|
||||||
"homeassistant": "0.44",
|
"homeassistant": "0.44.1",
|
||||||
"resinos": "0.7",
|
"resinos": "0.7",
|
||||||
"resinhup": "0.1",
|
"resinhup": "0.1",
|
||||||
"generic": "0.3"
|
"generic": "0.3"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user