Skip to content

Commit d98b4f0

Browse files
authored
Merge pull request #118 from home-assistant/dev
Release 0.49
2 parents 4753c05 + 8fee52d commit d98b4f0

File tree

12 files changed

+179
-30
lines changed

12 files changed

+179
-30
lines changed

API.md

Lines changed: 62 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
# HassIO Server
1+
# Hass.io Server
22

3-
## HassIO REST API
3+
## Hass.io RESTful API
44

5-
Interface for HomeAssistant to control things from supervisor.
5+
Interface for Home Assistant to control things from supervisor.
66

77
On error:
8+
89
```json
910
{
1011
"result": "error",
1112
"message": ""
1213
}
1314
```
1415

15-
On success
16+
On success:
17+
1618
```json
1719
{
1820
"result": "ok",
1921
"data": { }
2022
}
2123
```
2224

23-
### HassIO
25+
### Hass.io
2426

2527
- GET `/supervisor/ping`
26-
2728
- GET `/supervisor/info`
2829

2930
The addons from `addons` are only installed one.
@@ -54,14 +55,17 @@ The addons from `addons` are only installed one.
5455
```
5556

5657
- POST `/supervisor/update`
58+
5759
Optional:
60+
5861
```json
5962
{
6063
"version": "VERSION"
6164
}
6265
```
6366

6467
- POST `/supervisor/options`
68+
6569
```json
6670
{
6771
"beta_channel": "true|false",
@@ -78,11 +82,12 @@ Reload addons/version.
7882

7983
- GET `/supervisor/logs`
8084

81-
Output the raw docker log
85+
Output is the raw docker log.
8286

8387
### Security
8488

8589
- GET `/security/info`
90+
8691
```json
8792
{
8893
"initialize": "bool",
@@ -91,13 +96,15 @@ Output the raw docker log
9196
```
9297

9398
- POST `/security/options`
99+
94100
```json
95101
{
96102
"password": "xy"
97103
}
98104
```
99105

100106
- POST `/security/totp`
107+
101108
```json
102109
{
103110
"password": "xy"
@@ -117,6 +124,7 @@ Return QR-Code
117124
### Backup/Snapshot
118125

119126
- GET `/snapshots`
127+
120128
```json
121129
{
122130
"snapshots": [
@@ -132,13 +140,15 @@ Return QR-Code
132140
- POST `/snapshots/reload`
133141

134142
- POST `/snapshots/new/full`
143+
135144
```json
136145
{
137146
"name": "Optional"
138147
}
139148
```
140149

141150
- POST `/snapshots/new/partial`
151+
142152
```json
143153
{
144154
"name": "Optional",
@@ -150,6 +160,7 @@ Return QR-Code
150160
- POST `/snapshots/reload`
151161

152162
- GET `/snapshots/{slug}/info`
163+
153164
```json
154165
{
155166
"slug": "SNAPSHOT ID",
@@ -174,10 +185,9 @@ Return QR-Code
174185
```
175186

176187
- POST `/snapshots/{slug}/remove`
177-
178188
- POST `/snapshots/{slug}/restore/full`
179-
180189
- POST `/snapshots/{slug}/restore/partial`
190+
181191
```json
182192
{
183193
"homeassistant": "bool",
@@ -187,14 +197,14 @@ Return QR-Code
187197
```
188198

189199
### Host
190-
- POST `/host/reload`
191200

201+
- POST `/host/reload`
192202
- POST `/host/shutdown`
193-
194203
- POST `/host/reboot`
195-
196204
- GET `/host/info`
205+
197206
See HostControl info command.
207+
198208
```json
199209
{
200210
"type": "",
@@ -207,23 +217,45 @@ See HostControl info command.
207217
```
208218

209219
- POST `/host/update`
220+
210221
Optional:
222+
211223
```json
212224
{
213225
"version": "VERSION"
214226
}
215227
```
216228

229+
- GET `/host/hardware`
230+
```json
231+
{
232+
"serial": ["/dev/xy"],
233+
"input": ["Input device name"],
234+
"disk": ["/dev/sdax"],
235+
"audio": {
236+
"CARD_ID": {
237+
"name": "xy",
238+
"type": "microphone",
239+
"devices": {
240+
"DEV_ID": "type of device"
241+
}
242+
}
243+
}
244+
}
245+
```
246+
217247
### Network
218248

219249
- GET `/network/info`
250+
220251
```json
221252
{
222253
"hostname": ""
223254
}
224255
```
225256

226257
- POST `/network/options`
258+
227259
```json
228260
{
229261
"hostname": "",
@@ -235,7 +267,7 @@ Optional:
235267
}
236268
```
237269

238-
### HomeAssistant
270+
### Home Assistant
239271

240272
- GET `/homeassistant/info`
241273

@@ -250,7 +282,9 @@ Optional:
250282
```
251283

252284
- POST `/homeassistant/update`
285+
253286
Optional:
287+
254288
```json
255289
{
256290
"version": "VERSION"
@@ -259,11 +293,11 @@ Optional:
259293

260294
- GET `/homeassistant/logs`
261295

262-
Output the raw docker log
296+
Output is the raw Docker log.
263297

264298
- POST `/homeassistant/restart`
265-
266299
- POST `/homeassistant/options`
300+
267301
```json
268302
{
269303
"devices": [],
@@ -274,11 +308,11 @@ Output the raw docker log
274308

275309
Image with `null` and last_version with `null` reset this options.
276310

277-
### REST API addons
311+
### RESTful for API addons
278312

279313
- GET `/addons`
280314

281-
Get all available addons
315+
Get all available addons.
282316

283317
```json
284318
{
@@ -312,8 +346,8 @@ Get all available addons
312346
```
313347

314348
- POST `/addons/reload`
315-
316349
- GET `/addons/{addon}/info`
350+
317351
```json
318352
{
319353
"name": "xy bla",
@@ -340,6 +374,7 @@ Get all available addons
340374
- GET `/addons/{addon}/logo`
341375

342376
- POST `/addons/{addon}/options`
377+
343378
```json
344379
{
345380
"boot": "auto|manual",
@@ -358,7 +393,9 @@ For reset custom network settings, set it `null`.
358393
- POST `/addons/{addon}/stop`
359394

360395
- POST `/addons/{addon}/install`
396+
361397
Optional:
398+
362399
```json
363400
{
364401
"version": "VERSION"
@@ -368,7 +405,9 @@ Optional:
368405
- POST `/addons/{addon}/uninstall`
369406

370407
- POST `/addons/{addon}/update`
408+
371409
Optional:
410+
372411
```json
373412
{
374413
"version": "VERSION"
@@ -377,15 +416,16 @@ Optional:
377416

378417
- GET `/addons/{addon}/logs`
379418

380-
Output the raw docker log
419+
Output is the raw Docker log.
381420

382421
- POST `/addons/{addon}/restart`
383422

384423
## Host Control
385424

386-
Communicate over unix socket with a host daemon.
425+
Communicate over UNIX socket with a host daemon.
387426

388427
- commands
428+
389429
```
390430
# info
391431
-> {'type', 'version', 'last_version', 'features', 'hostname'}
@@ -404,7 +444,8 @@ Communicate over unix socket with a host daemon.
404444
# network int route xy
405445
```
406446

407-
features:
447+
Features:
448+
408449
- shutdown
409450
- reboot
410451
- update

hassio/api/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ def __init__(self, config, loop):
2828
self._handler = None
2929
self.server = None
3030

31-
def register_host(self, host_control):
31+
def register_host(self, host_control, hardware):
3232
"""Register hostcontrol function."""
33-
api_host = APIHost(self.config, self.loop, host_control)
33+
api_host = APIHost(self.config, self.loop, host_control, hardware)
3434

3535
self.webapp.router.add_get('/host/info', api_host.info)
36+
self.webapp.router.add_get('/host/hardware', api_host.hardware)
3637
self.webapp.router.add_post('/host/reboot', api_host.reboot)
3738
self.webapp.router.add_post('/host/shutdown', api_host.shutdown)
3839
self.webapp.router.add_post('/host/update', api_host.update)

hassio/api/host.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .util import api_process_hostcontrol, api_process, api_validate
88
from ..const import (
99
ATTR_VERSION, ATTR_LAST_VERSION, ATTR_TYPE, ATTR_HOSTNAME, ATTR_FEATURES,
10-
ATTR_OS)
10+
ATTR_OS, ATTR_SERIAL, ATTR_INPUT, ATTR_DISK, ATTR_AUDIO)
1111

1212
_LOGGER = logging.getLogger(__name__)
1313

@@ -19,11 +19,12 @@
1919
class APIHost(object):
2020
"""Handle rest api for host functions."""
2121

22-
def __init__(self, config, loop, host_control):
22+
def __init__(self, config, loop, host_control, hardware):
2323
"""Initialize host rest api part."""
2424
self.config = config
2525
self.loop = loop
2626
self.host_control = host_control
27+
self.local_hw = hardware
2728

2829
@api_process
2930
async def info(self, request):
@@ -58,3 +59,13 @@ async def update(self, request):
5859

5960
return await asyncio.shield(
6061
self.host_control.update(version=version), loop=self.loop)
62+
63+
@api_process
64+
async def hardware(self, request):
65+
"""Return local hardware infos."""
66+
return {
67+
ATTR_SERIAL: self.local_hw.serial_devices,
68+
ATTR_INPUT: self.local_hw.input_devices,
69+
ATTR_DISK: self.local_hw.disk_devices,
70+
ATTR_AUDIO: self.local_hw.audio_devices,
71+
}

hassio/const.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Const file for HassIO."""
22
from pathlib import Path
33

4-
HASSIO_VERSION = '0.48'
4+
HASSIO_VERSION = '0.49'
55

66
URL_HASSIO_VERSION = ('https://raw.githubusercontent.com/home-assistant/'
77
'hassio/master/version.json')
@@ -101,6 +101,10 @@
101101
ATTR_TIMEOUT = 'timeout'
102102
ATTR_AUTO_UPDATE = 'auto_update'
103103
ATTR_CUSTOM = 'custom'
104+
ATTR_AUDIO = 'audio'
105+
ATTR_INPUT = 'input'
106+
ATTR_DISK = 'disk'
107+
ATTR_SERIAL = 'serial'
104108

105109
STARTUP_INITIALIZE = 'initialize'
106110
STARTUP_SYSTEM = 'system'

0 commit comments

Comments
 (0)