diff --git a/API.md b/API.md index 924e375a69e..aada231dede 100644 --- a/API.md +++ b/API.md @@ -203,7 +203,8 @@ Optional: ```json { "version": "INSTALL_VERSION", - "last_version": "LAST_VERSION" + "last_version": "LAST_VERSION", + "devices": [] } ``` @@ -221,6 +222,13 @@ Output the raw docker log - POST `/homeassistant/restart` +- POST `/homeassistant/options` +```json +{ + "devices": [], +} +``` + ### REST API addons - GET `/addons/{addon}/info` diff --git a/README.md b/README.md index 45c0c12721a..5f90e0d2ea9 100644 --- a/README.md +++ b/README.md @@ -12,15 +12,3 @@ Hass.io is a Docker based system for managing your Home Assistant installation a ## Installation Installation instructions can be found at [https://home-assistant.io/hassio](https://home-assistant.io/hassio). - -# HomeAssistant - -## SSL - -All addons that create SSL certs follow the same file structure. If you use one, put follow lines in your `configuration.yaml`. - -```yaml -http: - ssl_certificate: /ssl/fullchain.pem - ssl_key: /ssl/privkey.pem -``` diff --git a/hassio/api/__init__.py b/hassio/api/__init__.py index 73527d01034..97c38c3893e 100644 --- a/hassio/api/__init__.py +++ b/hassio/api/__init__.py @@ -65,6 +65,7 @@ def register_homeassistant(self, dock_homeassistant): api_hass = APIHomeAssistant(self.config, self.loop, dock_homeassistant) self.webapp.router.add_get('/homeassistant/info', api_hass.info) + self.webapp.router.add_post('/homeassistant/options', api_hass.options) self.webapp.router.add_post('/homeassistant/update', api_hass.update) self.webapp.router.add_post('/homeassistant/restart', api_hass.restart) self.webapp.router.add_get('/homeassistant/logs', api_hass.logs) diff --git a/hassio/api/homeassistant.py b/hassio/api/homeassistant.py index 8410fe7d596..e5b7c761d10 100644 --- a/hassio/api/homeassistant.py +++ b/hassio/api/homeassistant.py @@ -5,10 +5,15 @@ import voluptuous as vol from .util import api_process, api_process_raw, api_validate -from ..const import ATTR_VERSION, ATTR_LAST_VERSION +from ..const import ATTR_VERSION, ATTR_LAST_VERSION, ATTR_DEVICES _LOGGER = logging.getLogger(__name__) + +SCHEMA_OPTIONS = vol.Schema({ + vol.Optional(ATTR_DEVICES): [vol.Coerce(str)], +}) + SCHEMA_VERSION = vol.Schema({ vol.Optional(ATTR_VERSION): vol.Coerce(str), }) @@ -29,8 +34,19 @@ async def info(self, request): return { ATTR_VERSION: self.homeassistant.version, ATTR_LAST_VERSION: self.config.last_homeassistant, + ATTR_DEVICES: self.config.homeassistant_devices, } + @api_process + async def options(self, request): + """Set homeassistant options.""" + body = await api_validate(SCHEMA_OPTIONS, request) + + if ATTR_DEVICES in body: + self.config.homeassistant_devices = body[ATTR_DEVICES] + + return True + @api_process async def update(self, request): """Update homeassistant.""" diff --git a/hassio/config.py b/hassio/config.py index cfc29130e2b..00f074c4d27 100644 --- a/hassio/config.py +++ b/hassio/config.py @@ -18,6 +18,7 @@ HOMEASSISTANT_CONFIG = PurePath("homeassistant") HOMEASSISTANT_LAST = 'homeassistant_last' +HOMEASSISTANT_DEVICES = 'homeassistant_devices' HASSIO_SSL = PurePath("ssl") HASSIO_LAST = 'hassio_last' @@ -49,6 +50,7 @@ vol.Optional(API_ENDPOINT): vol.Coerce(str), vol.Optional(TIMEZONE, default='UTC'): validate_timezone, vol.Optional(HOMEASSISTANT_LAST): vol.Coerce(str), + vol.Optional(HOMEASSISTANT_DEVICES, default=[]): [vol.Coerce(str)], vol.Optional(HASSIO_LAST): vol.Coerce(str), vol.Optional(ADDONS_CUSTOM_LIST, default=[]): [vol.Url()], vol.Optional(SECURITY_INITIALIZE, default=False): vol.Boolean(), @@ -134,6 +136,7 @@ def upstream_beta(self): def upstream_beta(self, value): """Set beta upstream mode.""" self._data[UPSTREAM_BETA] = bool(value) + self.save() @property def timezone(self): @@ -146,6 +149,17 @@ def timezone(self, value): self._data[TIMEZONE] = value self.save() + @property + def homeassistant_devices(self): + """Return list of special device to map into homeassistant.""" + return self._data[HOMEASSISTANT_DEVICES] + + @homeassistant_devices.setter + def homeassistant_devices(self, value): + """Set list of special device.""" + self._data[HOMEASSISTANT_DEVICES] = value + self.save() + @property def homeassistant_image(self): """Return docker homeassistant repository.""" diff --git a/hassio/const.py b/hassio/const.py index af7b6732708..4115db46cb0 100644 --- a/hassio/const.py +++ b/hassio/const.py @@ -1,7 +1,7 @@ """Const file for HassIO.""" from pathlib import Path -HASSIO_VERSION = '0.34' +HASSIO_VERSION = '0.35' URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/' 'hassio/master/version.json') diff --git a/hassio/dock/homeassistant.py b/hassio/dock/homeassistant.py index 6ce9f46027e..7b361bf5b79 100644 --- a/hassio/dock/homeassistant.py +++ b/hassio/dock/homeassistant.py @@ -22,6 +22,18 @@ def name(self): """Return name of docker container.""" return HASS_DOCKER_NAME + @property + def devices(self): + """Create list of special device to map into docker.""" + if not self.config.homeassistant_devices: + return + + devices = [] + for device in self.config.homeassistant_devices: + devices.append("/dev/{0}:/dev/{0}:rwm".format(device)) + + return devices + def _run(self): """Run docker image. @@ -39,6 +51,7 @@ def _run(self): name=self.name, detach=True, privileged=True, + devices=self.devices, network_mode='host', environment={ 'HASSIO': self.config.api_endpoint, diff --git a/version.json b/version.json index 6a9da94a901..17da72dad01 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "hassio": "0.34", + "hassio": "0.35", "homeassistant": "0.45.1", "resinos": "0.8", "resinhup": "0.1",