Skip to content

Commit

Permalink
Merge pull request #76 from home-assistant/dev
Browse files Browse the repository at this point in the history
Release 0.35
  • Loading branch information
pvizeli authored Jun 2, 2017
2 parents 2a09b70 + 255a33f commit df8afb3
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 16 deletions.
10 changes: 9 additions & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ Optional:
```json
{
"version": "INSTALL_VERSION",
"last_version": "LAST_VERSION"
"last_version": "LAST_VERSION",
"devices": []
}
```

Expand All @@ -221,6 +222,13 @@ Output the raw docker log

- POST `/homeassistant/restart`

- POST `/homeassistant/options`
```json
{
"devices": [],
}
```

### REST API addons

- GET `/addons/{addon}/info`
Expand Down
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
1 change: 1 addition & 0 deletions hassio/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 17 additions & 1 deletion hassio/api/homeassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
Expand All @@ -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."""
Expand Down
14 changes: 14 additions & 0 deletions hassio/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

HOMEASSISTANT_CONFIG = PurePath("homeassistant")
HOMEASSISTANT_LAST = 'homeassistant_last'
HOMEASSISTANT_DEVICES = 'homeassistant_devices'

HASSIO_SSL = PurePath("ssl")
HASSIO_LAST = 'hassio_last'
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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):
Expand All @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion hassio/const.py
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
13 changes: 13 additions & 0 deletions hassio/dock/homeassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"hassio": "0.34",
"hassio": "0.35",
"homeassistant": "0.45.1",
"resinos": "0.8",
"resinhup": "0.1",
Expand Down

1 comment on commit df8afb3

@andreipopovici
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @pvizeli, awesome work!

Please sign in to comment.