mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-08-24 08:29:21 +00:00
Compare commits
47 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d98b4f039f | ||
![]() |
8fee52da5e | ||
![]() |
0f9ad3658b | ||
![]() |
1155ee07e5 | ||
![]() |
fa687e982e | ||
![]() |
4e902af937 | ||
![]() |
6455ad14a7 | ||
![]() |
4753c058a3 | ||
![]() |
1567cbfe37 | ||
![]() |
3ed66c802e | ||
![]() |
980baf23a8 | ||
![]() |
d69af6a62b | ||
![]() |
863456525f | ||
![]() |
dae49df7b1 | ||
![]() |
282fc03687 | ||
![]() |
f9f7e07c52 | ||
![]() |
12a2ccf0ec | ||
![]() |
a98d76618a | ||
![]() |
7a59e7392b | ||
![]() |
446aff3fa6 | ||
![]() |
3272403141 | ||
![]() |
d1f265da9e | ||
![]() |
4915c935dd | ||
![]() |
e78d935824 | ||
![]() |
934ca64a32 | ||
![]() |
0860e6d202 | ||
![]() |
c3e1c8b58e | ||
![]() |
44e48095c7 | ||
![]() |
a13eb7841d | ||
![]() |
b5701c5878 | ||
![]() |
803eb0f8c9 | ||
![]() |
58c5ed7ba1 | ||
![]() |
c4d7d671d1 | ||
![]() |
9d88255225 | ||
![]() |
bfbc366f55 | ||
![]() |
0f30a23f3e | ||
![]() |
7e1bb42bb7 | ||
![]() |
251a43216e | ||
![]() |
4801b9903c | ||
![]() |
cd5a09938f | ||
![]() |
14bf834224 | ||
![]() |
8aec943a5c | ||
![]() |
d817e75d98 | ||
![]() |
fbd8abdcd5 | ||
![]() |
ca02977505 | ||
![]() |
6533b57c6d | ||
![]() |
0a818282d3 |
106
API.md
106
API.md
@@ -1,10 +1,11 @@
|
|||||||
# HassIO Server
|
# Hass.io Server
|
||||||
|
|
||||||
## HassIO REST API
|
## Hass.io RESTful API
|
||||||
|
|
||||||
Interface for HomeAssistant to control things from supervisor.
|
Interface for Home Assistant to control things from supervisor.
|
||||||
|
|
||||||
On error:
|
On error:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"result": "error",
|
"result": "error",
|
||||||
@@ -12,7 +13,8 @@ On error:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
On success
|
On success:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"result": "ok",
|
"result": "ok",
|
||||||
@@ -20,10 +22,9 @@ On success
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### HassIO
|
### Hass.io
|
||||||
|
|
||||||
- GET `/supervisor/ping`
|
- GET `/supervisor/ping`
|
||||||
|
|
||||||
- GET `/supervisor/info`
|
- GET `/supervisor/info`
|
||||||
|
|
||||||
The addons from `addons` are only installed one.
|
The addons from `addons` are only installed one.
|
||||||
@@ -40,13 +41,11 @@ The addons from `addons` are only installed one.
|
|||||||
"name": "xy bla",
|
"name": "xy bla",
|
||||||
"slug": "xy",
|
"slug": "xy",
|
||||||
"description": "description",
|
"description": "description",
|
||||||
"arch": ["armhf", "aarch64", "i386", "amd64"],
|
|
||||||
"repository": "12345678|null",
|
"repository": "12345678|null",
|
||||||
"version": "LAST_VERSION",
|
"version": "LAST_VERSION",
|
||||||
"installed": "INSTALL_VERSION",
|
"installed": "INSTALL_VERSION",
|
||||||
"detached": "bool",
|
"logo": "bool",
|
||||||
"build": "bool",
|
"state": "started|stopped",
|
||||||
"url": "null|url"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"addons_repositories": [
|
"addons_repositories": [
|
||||||
@@ -55,12 +54,10 @@ The addons from `addons` are only installed one.
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- GET `/supervisor/addons`
|
|
||||||
|
|
||||||
Get all available addons. Will be delete soon. Look to `/addons`
|
|
||||||
|
|
||||||
- POST `/supervisor/update`
|
- POST `/supervisor/update`
|
||||||
|
|
||||||
Optional:
|
Optional:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version": "VERSION"
|
"version": "VERSION"
|
||||||
@@ -68,6 +65,7 @@ Optional:
|
|||||||
```
|
```
|
||||||
|
|
||||||
- POST `/supervisor/options`
|
- POST `/supervisor/options`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"beta_channel": "true|false",
|
"beta_channel": "true|false",
|
||||||
@@ -84,11 +82,12 @@ Reload addons/version.
|
|||||||
|
|
||||||
- GET `/supervisor/logs`
|
- GET `/supervisor/logs`
|
||||||
|
|
||||||
Output the raw docker log
|
Output is the raw docker log.
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
||||||
- GET `/security/info`
|
- GET `/security/info`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"initialize": "bool",
|
"initialize": "bool",
|
||||||
@@ -97,6 +96,7 @@ Output the raw docker log
|
|||||||
```
|
```
|
||||||
|
|
||||||
- POST `/security/options`
|
- POST `/security/options`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"password": "xy"
|
"password": "xy"
|
||||||
@@ -104,6 +104,7 @@ Output the raw docker log
|
|||||||
```
|
```
|
||||||
|
|
||||||
- POST `/security/totp`
|
- POST `/security/totp`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"password": "xy"
|
"password": "xy"
|
||||||
@@ -123,6 +124,7 @@ Return QR-Code
|
|||||||
### Backup/Snapshot
|
### Backup/Snapshot
|
||||||
|
|
||||||
- GET `/snapshots`
|
- GET `/snapshots`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"snapshots": [
|
"snapshots": [
|
||||||
@@ -138,6 +140,7 @@ Return QR-Code
|
|||||||
- POST `/snapshots/reload`
|
- POST `/snapshots/reload`
|
||||||
|
|
||||||
- POST `/snapshots/new/full`
|
- POST `/snapshots/new/full`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"name": "Optional"
|
"name": "Optional"
|
||||||
@@ -145,6 +148,7 @@ Return QR-Code
|
|||||||
```
|
```
|
||||||
|
|
||||||
- POST `/snapshots/new/partial`
|
- POST `/snapshots/new/partial`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"name": "Optional",
|
"name": "Optional",
|
||||||
@@ -156,6 +160,7 @@ Return QR-Code
|
|||||||
- POST `/snapshots/reload`
|
- POST `/snapshots/reload`
|
||||||
|
|
||||||
- GET `/snapshots/{slug}/info`
|
- GET `/snapshots/{slug}/info`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"slug": "SNAPSHOT ID",
|
"slug": "SNAPSHOT ID",
|
||||||
@@ -180,10 +185,9 @@ Return QR-Code
|
|||||||
```
|
```
|
||||||
|
|
||||||
- POST `/snapshots/{slug}/remove`
|
- POST `/snapshots/{slug}/remove`
|
||||||
|
|
||||||
- POST `/snapshots/{slug}/restore/full`
|
- POST `/snapshots/{slug}/restore/full`
|
||||||
|
|
||||||
- POST `/snapshots/{slug}/restore/partial`
|
- POST `/snapshots/{slug}/restore/partial`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"homeassistant": "bool",
|
"homeassistant": "bool",
|
||||||
@@ -193,14 +197,14 @@ Return QR-Code
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Host
|
### Host
|
||||||
|
|
||||||
- POST `/host/reload`
|
- POST `/host/reload`
|
||||||
|
|
||||||
- POST `/host/shutdown`
|
- POST `/host/shutdown`
|
||||||
|
|
||||||
- POST `/host/reboot`
|
- POST `/host/reboot`
|
||||||
|
|
||||||
- GET `/host/info`
|
- GET `/host/info`
|
||||||
|
|
||||||
See HostControl info command.
|
See HostControl info command.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"type": "",
|
"type": "",
|
||||||
@@ -213,16 +217,37 @@ See HostControl info command.
|
|||||||
```
|
```
|
||||||
|
|
||||||
- POST `/host/update`
|
- POST `/host/update`
|
||||||
|
|
||||||
Optional:
|
Optional:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version": "VERSION"
|
"version": "VERSION"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- GET `/host/hardware`
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"serial": ["/dev/xy"],
|
||||||
|
"input": ["Input device name"],
|
||||||
|
"disk": ["/dev/sdax"],
|
||||||
|
"audio": {
|
||||||
|
"CARD_ID": {
|
||||||
|
"name": "xy",
|
||||||
|
"type": "microphone",
|
||||||
|
"devices": {
|
||||||
|
"DEV_ID": "type of device"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Network
|
### Network
|
||||||
|
|
||||||
- GET `/network/info`
|
- GET `/network/info`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"hostname": ""
|
"hostname": ""
|
||||||
@@ -230,6 +255,7 @@ Optional:
|
|||||||
```
|
```
|
||||||
|
|
||||||
- POST `/network/options`
|
- POST `/network/options`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"hostname": "",
|
"hostname": "",
|
||||||
@@ -241,7 +267,7 @@ Optional:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### HomeAssistant
|
### Home Assistant
|
||||||
|
|
||||||
- GET `/homeassistant/info`
|
- GET `/homeassistant/info`
|
||||||
|
|
||||||
@@ -256,7 +282,9 @@ Optional:
|
|||||||
```
|
```
|
||||||
|
|
||||||
- POST `/homeassistant/update`
|
- POST `/homeassistant/update`
|
||||||
|
|
||||||
Optional:
|
Optional:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version": "VERSION"
|
"version": "VERSION"
|
||||||
@@ -265,11 +293,11 @@ Optional:
|
|||||||
|
|
||||||
- GET `/homeassistant/logs`
|
- GET `/homeassistant/logs`
|
||||||
|
|
||||||
Output the raw docker log
|
Output is the raw Docker log.
|
||||||
|
|
||||||
- POST `/homeassistant/restart`
|
- POST `/homeassistant/restart`
|
||||||
|
|
||||||
- POST `/homeassistant/options`
|
- POST `/homeassistant/options`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"devices": [],
|
"devices": [],
|
||||||
@@ -280,11 +308,11 @@ Output the raw docker log
|
|||||||
|
|
||||||
Image with `null` and last_version with `null` reset this options.
|
Image with `null` and last_version with `null` reset this options.
|
||||||
|
|
||||||
### REST API addons
|
### RESTful for API addons
|
||||||
|
|
||||||
- GET `/addons`
|
- GET `/addons`
|
||||||
|
|
||||||
Get all available addons
|
Get all available addons.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -299,7 +327,10 @@ Get all available addons
|
|||||||
"installed": "none|INSTALL_VERSION",
|
"installed": "none|INSTALL_VERSION",
|
||||||
"detached": "bool",
|
"detached": "bool",
|
||||||
"build": "bool",
|
"build": "bool",
|
||||||
"url": "null|url"
|
"privileged": ["NET_ADMIN", "SYS_ADMIN"],
|
||||||
|
"devices": ["/dev/xy"],
|
||||||
|
"url": "null|url",
|
||||||
|
"logo": "bool"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"repositories": [
|
"repositories": [
|
||||||
@@ -315,8 +346,8 @@ Get all available addons
|
|||||||
```
|
```
|
||||||
|
|
||||||
- POST `/addons/reload`
|
- POST `/addons/reload`
|
||||||
|
|
||||||
- GET `/addons/{addon}/info`
|
- GET `/addons/{addon}/info`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"name": "xy bla",
|
"name": "xy bla",
|
||||||
@@ -332,11 +363,18 @@ Get all available addons
|
|||||||
"build": "bool",
|
"build": "bool",
|
||||||
"options": "{}",
|
"options": "{}",
|
||||||
"network": "{}|null",
|
"network": "{}|null",
|
||||||
"host_network": "bool"
|
"host_network": "bool",
|
||||||
|
"privileged": ["NET_ADMIN", "SYS_ADMIN"],
|
||||||
|
"devices": ["/dev/xy"],
|
||||||
|
"logo": "bool",
|
||||||
|
"webui": "null|http(s)://[HOST]:port/xy/zx"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- GET `/addons/{addon}/logo`
|
||||||
|
|
||||||
- POST `/addons/{addon}/options`
|
- POST `/addons/{addon}/options`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"boot": "auto|manual",
|
"boot": "auto|manual",
|
||||||
@@ -355,7 +393,9 @@ For reset custom network settings, set it `null`.
|
|||||||
- POST `/addons/{addon}/stop`
|
- POST `/addons/{addon}/stop`
|
||||||
|
|
||||||
- POST `/addons/{addon}/install`
|
- POST `/addons/{addon}/install`
|
||||||
|
|
||||||
Optional:
|
Optional:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version": "VERSION"
|
"version": "VERSION"
|
||||||
@@ -365,7 +405,9 @@ Optional:
|
|||||||
- POST `/addons/{addon}/uninstall`
|
- POST `/addons/{addon}/uninstall`
|
||||||
|
|
||||||
- POST `/addons/{addon}/update`
|
- POST `/addons/{addon}/update`
|
||||||
|
|
||||||
Optional:
|
Optional:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"version": "VERSION"
|
"version": "VERSION"
|
||||||
@@ -374,15 +416,16 @@ Optional:
|
|||||||
|
|
||||||
- GET `/addons/{addon}/logs`
|
- GET `/addons/{addon}/logs`
|
||||||
|
|
||||||
Output the raw docker log
|
Output is the raw Docker log.
|
||||||
|
|
||||||
- POST `/addons/{addon}/restart`
|
- POST `/addons/{addon}/restart`
|
||||||
|
|
||||||
## Host Control
|
## Host Control
|
||||||
|
|
||||||
Communicate over unix socket with a host daemon.
|
Communicate over UNIX socket with a host daemon.
|
||||||
|
|
||||||
- commands
|
- commands
|
||||||
|
|
||||||
```
|
```
|
||||||
# info
|
# info
|
||||||
-> {'type', 'version', 'last_version', 'features', 'hostname'}
|
-> {'type', 'version', 'last_version', 'features', 'hostname'}
|
||||||
@@ -401,7 +444,8 @@ Communicate over unix socket with a host daemon.
|
|||||||
# network int route xy
|
# network int route xy
|
||||||
```
|
```
|
||||||
|
|
||||||
features:
|
Features:
|
||||||
|
|
||||||
- shutdown
|
- shutdown
|
||||||
- reboot
|
- reboot
|
||||||
- update
|
- update
|
||||||
|
218
LICENSE
218
LICENSE
@@ -1,29 +1,201 @@
|
|||||||
BSD 3-Clause License
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
Copyright (c) 2017, Pascal Vizeli
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
1. Definitions.
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
list of conditions and the following disclaimer.
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
this list of conditions and the following disclaimer in the documentation
|
the copyright owner that is granting the License.
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of the copyright holder nor the names of its
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
contributors may be used to endorse or promote products derived from
|
other entities that control, are controlled by, or are under common
|
||||||
this software without specific prior written permission.
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
exercising permissions granted by this License.
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
including but not limited to software source code, documentation
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
source, and configuration files.
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
"Object" form shall mean any form resulting from mechanical
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
transformation or translation of a Source form, including but
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright 2017 Pascal Vizeli
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# HassIO
|
# Hass.io
|
||||||
### First private cloud solution for home automation.
|
### First private cloud solution for home automation.
|
||||||
|
|
||||||
Hass.io is a Docker based system for managing your Home Assistant installation and related applications. The system is controlled via Home Assistant which communicates with the supervisor. The supervisor provides an API to manage the installation. This includes changing network settings or installing and updating software.
|
Hass.io is a Docker based system for managing your Home Assistant installation and related applications. The system is controlled via Home Assistant which communicates with the supervisor. The supervisor provides an API to manage the installation. This includes changing network settings or installing and updating software.
|
||||||
@@ -7,8 +7,6 @@ Hass.io is a Docker based system for managing your Home Assistant installation a
|
|||||||
|
|
||||||
[HassIO-Addons](https://github.com/home-assistant/hassio-addons) | [HassIO-Build](https://github.com/home-assistant/hassio-build)
|
[HassIO-Addons](https://github.com/home-assistant/hassio-addons) | [HassIO-Build](https://github.com/home-assistant/hassio-build)
|
||||||
|
|
||||||
**HassIO is under active development and is not ready yet for production use.**
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Installation instructions can be found at [https://home-assistant.io/hassio](https://home-assistant.io/hassio).
|
Installation instructions can be found at [https://home-assistant.io/hassio](https://home-assistant.io/hassio).
|
||||||
|
@@ -19,7 +19,7 @@ from ..const import (
|
|||||||
ATTR_URL, ATTR_ARCH, ATTR_LOCATON, ATTR_DEVICES, ATTR_ENVIRONMENT,
|
ATTR_URL, ATTR_ARCH, ATTR_LOCATON, ATTR_DEVICES, ATTR_ENVIRONMENT,
|
||||||
ATTR_HOST_NETWORK, ATTR_TMPFS, ATTR_PRIVILEGED, ATTR_STARTUP,
|
ATTR_HOST_NETWORK, ATTR_TMPFS, ATTR_PRIVILEGED, ATTR_STARTUP,
|
||||||
STATE_STARTED, STATE_STOPPED, STATE_NONE, ATTR_USER, ATTR_SYSTEM,
|
STATE_STARTED, STATE_STOPPED, STATE_NONE, ATTR_USER, ATTR_SYSTEM,
|
||||||
ATTR_STATE, ATTR_TIMEOUT, ATTR_AUTO_UPDATE, ATTR_NETWORK)
|
ATTR_STATE, ATTR_TIMEOUT, ATTR_AUTO_UPDATE, ATTR_NETWORK, ATTR_WEBUI)
|
||||||
from .util import check_installed
|
from .util import check_installed
|
||||||
from ..dock.addon import DockerAddon
|
from ..dock.addon import DockerAddon
|
||||||
from ..tools import write_json_file, read_json_file
|
from ..tools import write_json_file, read_json_file
|
||||||
@@ -27,6 +27,7 @@ from ..tools import write_json_file, read_json_file
|
|||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
RE_VOLUME = re.compile(MAP_VOLUME)
|
RE_VOLUME = re.compile(MAP_VOLUME)
|
||||||
|
RE_WEBUI = re.compile(r"^(.*\[HOST\]:)\[PORT:(\d+)\](.*)$")
|
||||||
|
|
||||||
|
|
||||||
class Addon(object):
|
class Addon(object):
|
||||||
@@ -130,7 +131,8 @@ class Addon(object):
|
|||||||
@property
|
@property
|
||||||
def auto_update(self):
|
def auto_update(self):
|
||||||
"""Return if auto update is enable."""
|
"""Return if auto update is enable."""
|
||||||
return self.data.user[self._id][ATTR_AUTO_UPDATE]
|
if ATTR_AUTO_UPDATE in self.data.user.get(self._id, {}):
|
||||||
|
return self.data.user[self._id][ATTR_AUTO_UPDATE]
|
||||||
|
|
||||||
@auto_update.setter
|
@auto_update.setter
|
||||||
def auto_update(self, value):
|
def auto_update(self, value):
|
||||||
@@ -196,6 +198,25 @@ class Addon(object):
|
|||||||
|
|
||||||
self.data.save()
|
self.data.save()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def webui(self):
|
||||||
|
"""Return URL to webui or None."""
|
||||||
|
if ATTR_WEBUI not in self._mesh:
|
||||||
|
return
|
||||||
|
|
||||||
|
webui = self._mesh[ATTR_WEBUI]
|
||||||
|
dock_port = RE_WEBUI.sub(r"\2", webui)
|
||||||
|
if self.ports is None:
|
||||||
|
real_port = dock_port
|
||||||
|
else:
|
||||||
|
real_port = self.ports.get("{}/tcp".format(dock_port), dock_port)
|
||||||
|
|
||||||
|
# for interface config or port lists
|
||||||
|
if isinstance(real_port, (tuple, list)):
|
||||||
|
real_port = real_port[-1]
|
||||||
|
|
||||||
|
return RE_WEBUI.sub(r"\g<1>{}\g<3>".format(real_port), webui)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def network_mode(self):
|
def network_mode(self):
|
||||||
"""Return network mode of addon."""
|
"""Return network mode of addon."""
|
||||||
@@ -228,6 +249,11 @@ class Addon(object):
|
|||||||
"""Return url of addon."""
|
"""Return url of addon."""
|
||||||
return self._mesh.get(ATTR_URL)
|
return self._mesh.get(ATTR_URL)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def with_logo(self):
|
||||||
|
"""Return True if a logo exists."""
|
||||||
|
return self.path_logo.exists()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_arch(self):
|
def supported_arch(self):
|
||||||
"""Return list of supported arch."""
|
"""Return list of supported arch."""
|
||||||
@@ -273,15 +299,20 @@ class Addon(object):
|
|||||||
return PurePath(self.config.path_extern_addons_data, self._id)
|
return PurePath(self.config.path_extern_addons_data, self._id)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_addon_options(self):
|
def path_options(self):
|
||||||
"""Return path to addons options."""
|
"""Return path to addons options."""
|
||||||
return Path(self.path_data, "options.json")
|
return Path(self.path_data, "options.json")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path_addon_location(self):
|
def path_location(self):
|
||||||
"""Return path to this addon."""
|
"""Return path to this addon."""
|
||||||
return Path(self._mesh[ATTR_LOCATON])
|
return Path(self._mesh[ATTR_LOCATON])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def path_logo(self):
|
||||||
|
"""Return path to addon logo."""
|
||||||
|
return Path(self.path_location, 'logo.png')
|
||||||
|
|
||||||
def write_options(self):
|
def write_options(self):
|
||||||
"""Return True if addon options is written to data."""
|
"""Return True if addon options is written to data."""
|
||||||
schema = self.schema
|
schema = self.schema
|
||||||
@@ -289,7 +320,7 @@ class Addon(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
schema(options)
|
schema(options)
|
||||||
return write_json_file(self.path_addon_options, options)
|
return write_json_file(self.path_options, options)
|
||||||
except vol.Invalid as ex:
|
except vol.Invalid as ex:
|
||||||
_LOGGER.error("Addon %s have wrong options -> %s", self._id,
|
_LOGGER.error("Addon %s have wrong options -> %s", self._id,
|
||||||
humanize_error(options, ex))
|
humanize_error(options, ex))
|
||||||
@@ -305,6 +336,36 @@ class Addon(object):
|
|||||||
return vol.Schema(dict)
|
return vol.Schema(dict)
|
||||||
return vol.Schema(vol.All(dict, validate_options(raw_schema)))
|
return vol.Schema(vol.All(dict, validate_options(raw_schema)))
|
||||||
|
|
||||||
|
def test_udpate_schema(self):
|
||||||
|
"""Check if the exists config valid after update."""
|
||||||
|
if not self.is_installed or self.is_detached:
|
||||||
|
return True
|
||||||
|
|
||||||
|
# load next schema
|
||||||
|
new_raw_schema = self.data.cache[self._id][ATTR_SCHEMA]
|
||||||
|
default_options = self.data.cache[self._id][ATTR_OPTIONS]
|
||||||
|
|
||||||
|
# if disabled
|
||||||
|
if isinstance(new_raw_schema, bool):
|
||||||
|
return True
|
||||||
|
|
||||||
|
# merge options
|
||||||
|
options = {
|
||||||
|
**self.data.user[self._id][ATTR_OPTIONS],
|
||||||
|
**default_options,
|
||||||
|
}
|
||||||
|
|
||||||
|
# create voluptuous
|
||||||
|
new_schema = \
|
||||||
|
vol.Schema(vol.All(dict, validate_options(new_raw_schema)))
|
||||||
|
|
||||||
|
# validate
|
||||||
|
try:
|
||||||
|
new_schema(options)
|
||||||
|
except vol.Invalid:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
async def install(self, version=None):
|
async def install(self, version=None):
|
||||||
"""Install a addon."""
|
"""Install a addon."""
|
||||||
if self.config.arch not in self.supported_arch:
|
if self.config.arch not in self.supported_arch:
|
||||||
|
@@ -10,7 +10,7 @@ from ..const import (
|
|||||||
ARCH_AARCH64, ARCH_AMD64, ARCH_I386, ATTR_TMPFS, ATTR_PRIVILEGED,
|
ARCH_AARCH64, ARCH_AMD64, ARCH_I386, ATTR_TMPFS, ATTR_PRIVILEGED,
|
||||||
ATTR_USER, ATTR_STATE, ATTR_SYSTEM, STATE_STARTED, STATE_STOPPED,
|
ATTR_USER, ATTR_STATE, ATTR_SYSTEM, STATE_STARTED, STATE_STOPPED,
|
||||||
ATTR_LOCATON, ATTR_REPOSITORY, ATTR_TIMEOUT, ATTR_NETWORK,
|
ATTR_LOCATON, ATTR_REPOSITORY, ATTR_TIMEOUT, ATTR_NETWORK,
|
||||||
ATTR_AUTO_UPDATE)
|
ATTR_AUTO_UPDATE, ATTR_WEBUI)
|
||||||
from ..validate import NETWORK_PORT, DOCKER_PORTS
|
from ..validate import NETWORK_PORT, DOCKER_PORTS
|
||||||
|
|
||||||
|
|
||||||
@@ -35,8 +35,9 @@ STARTUP_ALL = [
|
|||||||
STARTUP_APPLICATION
|
STARTUP_APPLICATION
|
||||||
]
|
]
|
||||||
|
|
||||||
PRIVILEGE_ALL = [
|
PRIVILEGED_ALL = [
|
||||||
"NET_ADMIN"
|
"NET_ADMIN",
|
||||||
|
"SYS_ADMIN",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -65,13 +66,15 @@ SCHEMA_ADDON_CONFIG = vol.Schema({
|
|||||||
vol.Required(ATTR_BOOT):
|
vol.Required(ATTR_BOOT):
|
||||||
vol.In([BOOT_AUTO, BOOT_MANUAL]),
|
vol.In([BOOT_AUTO, BOOT_MANUAL]),
|
||||||
vol.Optional(ATTR_PORTS): DOCKER_PORTS,
|
vol.Optional(ATTR_PORTS): DOCKER_PORTS,
|
||||||
|
vol.Optional(ATTR_WEBUI):
|
||||||
|
vol.Match(r"^(?:https?):\/\/\[HOST\]:\[PORT:\d+\].*$"),
|
||||||
vol.Optional(ATTR_HOST_NETWORK, default=False): vol.Boolean(),
|
vol.Optional(ATTR_HOST_NETWORK, default=False): vol.Boolean(),
|
||||||
vol.Optional(ATTR_DEVICES): [vol.Match(r"^(.*):(.*):([rwm]{1,3})$")],
|
vol.Optional(ATTR_DEVICES): [vol.Match(r"^(.*):(.*):([rwm]{1,3})$")],
|
||||||
vol.Optional(ATTR_TMPFS):
|
vol.Optional(ATTR_TMPFS):
|
||||||
vol.Match(r"^size=(\d)*[kmg](,uid=\d{1,4})?(,rw)?$"),
|
vol.Match(r"^size=(\d)*[kmg](,uid=\d{1,4})?(,rw)?$"),
|
||||||
vol.Optional(ATTR_MAP, default=[]): [vol.Match(MAP_VOLUME)],
|
vol.Optional(ATTR_MAP, default=[]): [vol.Match(MAP_VOLUME)],
|
||||||
vol.Optional(ATTR_ENVIRONMENT): {vol.Match(r"\w*"): vol.Coerce(str)},
|
vol.Optional(ATTR_ENVIRONMENT): {vol.Match(r"\w*"): vol.Coerce(str)},
|
||||||
vol.Optional(ATTR_PRIVILEGED): [vol.In(PRIVILEGE_ALL)],
|
vol.Optional(ATTR_PRIVILEGED): [vol.In(PRIVILEGED_ALL)],
|
||||||
vol.Required(ATTR_OPTIONS): dict,
|
vol.Required(ATTR_OPTIONS): dict,
|
||||||
vol.Required(ATTR_SCHEMA): vol.Any(vol.Schema({
|
vol.Required(ATTR_SCHEMA): vol.Any(vol.Schema({
|
||||||
vol.Coerce(str): vol.Any(ADDON_ELEMENT, [
|
vol.Coerce(str): vol.Any(ADDON_ELEMENT, [
|
||||||
@@ -95,7 +98,7 @@ SCHEMA_REPOSITORY_CONFIG = vol.Schema({
|
|||||||
# pylint: disable=no-value-for-parameter
|
# pylint: disable=no-value-for-parameter
|
||||||
SCHEMA_ADDON_USER = vol.Schema({
|
SCHEMA_ADDON_USER = vol.Schema({
|
||||||
vol.Required(ATTR_VERSION): vol.Coerce(str),
|
vol.Required(ATTR_VERSION): vol.Coerce(str),
|
||||||
vol.Required(ATTR_OPTIONS): dict,
|
vol.Optional(ATTR_OPTIONS, default={}): dict,
|
||||||
vol.Optional(ATTR_AUTO_UPDATE, default=False): vol.Boolean(),
|
vol.Optional(ATTR_AUTO_UPDATE, default=False): vol.Boolean(),
|
||||||
vol.Optional(ATTR_BOOT):
|
vol.Optional(ATTR_BOOT):
|
||||||
vol.In([BOOT_AUTO, BOOT_MANUAL]),
|
vol.In([BOOT_AUTO, BOOT_MANUAL]),
|
||||||
|
@@ -28,11 +28,12 @@ class RestAPI(object):
|
|||||||
self._handler = None
|
self._handler = None
|
||||||
self.server = None
|
self.server = None
|
||||||
|
|
||||||
def register_host(self, host_control):
|
def register_host(self, host_control, hardware):
|
||||||
"""Register hostcontrol function."""
|
"""Register hostcontrol function."""
|
||||||
api_host = APIHost(self.config, self.loop, host_control)
|
api_host = APIHost(self.config, self.loop, host_control, hardware)
|
||||||
|
|
||||||
self.webapp.router.add_get('/host/info', api_host.info)
|
self.webapp.router.add_get('/host/info', api_host.info)
|
||||||
|
self.webapp.router.add_get('/host/hardware', api_host.hardware)
|
||||||
self.webapp.router.add_post('/host/reboot', api_host.reboot)
|
self.webapp.router.add_post('/host/reboot', api_host.reboot)
|
||||||
self.webapp.router.add_post('/host/shutdown', api_host.shutdown)
|
self.webapp.router.add_post('/host/shutdown', api_host.shutdown)
|
||||||
self.webapp.router.add_post('/host/update', api_host.update)
|
self.webapp.router.add_post('/host/update', api_host.update)
|
||||||
@@ -53,8 +54,6 @@ class RestAPI(object):
|
|||||||
|
|
||||||
self.webapp.router.add_get('/supervisor/ping', api_supervisor.ping)
|
self.webapp.router.add_get('/supervisor/ping', api_supervisor.ping)
|
||||||
self.webapp.router.add_get('/supervisor/info', api_supervisor.info)
|
self.webapp.router.add_get('/supervisor/info', api_supervisor.info)
|
||||||
self.webapp.router.add_get(
|
|
||||||
'/supervisor/addons', api_supervisor.available_addons)
|
|
||||||
self.webapp.router.add_post(
|
self.webapp.router.add_post(
|
||||||
'/supervisor/update', api_supervisor.update)
|
'/supervisor/update', api_supervisor.update)
|
||||||
self.webapp.router.add_post(
|
self.webapp.router.add_post(
|
||||||
@@ -94,6 +93,7 @@ class RestAPI(object):
|
|||||||
self.webapp.router.add_post(
|
self.webapp.router.add_post(
|
||||||
'/addons/{addon}/options', api_addons.options)
|
'/addons/{addon}/options', api_addons.options)
|
||||||
self.webapp.router.add_get('/addons/{addon}/logs', api_addons.logs)
|
self.webapp.router.add_get('/addons/{addon}/logs', api_addons.logs)
|
||||||
|
self.webapp.router.add_get('/addons/{addon}/logo', api_addons.logo)
|
||||||
|
|
||||||
def register_security(self):
|
def register_security(self):
|
||||||
"""Register security function."""
|
"""Register security function."""
|
||||||
|
@@ -11,7 +11,8 @@ from ..const import (
|
|||||||
ATTR_URL, ATTR_DESCRIPTON, ATTR_DETACHED, ATTR_NAME, ATTR_REPOSITORY,
|
ATTR_URL, ATTR_DESCRIPTON, ATTR_DETACHED, ATTR_NAME, ATTR_REPOSITORY,
|
||||||
ATTR_BUILD, ATTR_AUTO_UPDATE, ATTR_NETWORK, ATTR_HOST_NETWORK, ATTR_SLUG,
|
ATTR_BUILD, ATTR_AUTO_UPDATE, ATTR_NETWORK, ATTR_HOST_NETWORK, ATTR_SLUG,
|
||||||
ATTR_SOURCE, ATTR_REPOSITORIES, ATTR_ADDONS, ATTR_ARCH, ATTR_MAINTAINER,
|
ATTR_SOURCE, ATTR_REPOSITORIES, ATTR_ADDONS, ATTR_ARCH, ATTR_MAINTAINER,
|
||||||
ATTR_INSTALLED, BOOT_AUTO, BOOT_MANUAL)
|
ATTR_INSTALLED, ATTR_LOGO, ATTR_WEBUI, ATTR_DEVICES, ATTR_PRIVILEGED,
|
||||||
|
BOOT_AUTO, BOOT_MANUAL, CONTENT_TYPE_PNG, CONTENT_TYPE_BINARY)
|
||||||
from ..validate import DOCKER_PORTS
|
from ..validate import DOCKER_PORTS
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@@ -48,6 +49,14 @@ class APIAddons(object):
|
|||||||
|
|
||||||
return addon
|
return addon
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _pretty_devices(addon):
|
||||||
|
"""Return a simplified device list."""
|
||||||
|
dev_list = addon.devices
|
||||||
|
if not dev_list:
|
||||||
|
return
|
||||||
|
return [row.split(':')[0] for row in dev_list]
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def list(self, request):
|
async def list(self, request):
|
||||||
"""Return all addons / repositories ."""
|
"""Return all addons / repositories ."""
|
||||||
@@ -63,7 +72,10 @@ class APIAddons(object):
|
|||||||
ATTR_DETACHED: addon.is_detached,
|
ATTR_DETACHED: addon.is_detached,
|
||||||
ATTR_REPOSITORY: addon.repository,
|
ATTR_REPOSITORY: addon.repository,
|
||||||
ATTR_BUILD: addon.need_build,
|
ATTR_BUILD: addon.need_build,
|
||||||
|
ATTR_PRIVILEGED: addon.privileged,
|
||||||
|
ATTR_DEVICES: self._pretty_devices(addon),
|
||||||
ATTR_URL: addon.url,
|
ATTR_URL: addon.url,
|
||||||
|
ATTR_LOGO: addon.with_logo,
|
||||||
})
|
})
|
||||||
|
|
||||||
data_repositories = []
|
data_repositories = []
|
||||||
@@ -82,9 +94,10 @@ class APIAddons(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
def reload(self, request):
|
async def reload(self, request):
|
||||||
"""Reload all addons data."""
|
"""Reload all addons data."""
|
||||||
return self.addons.reload()
|
await asyncio.shield(self.addons.reload(), loop=self.loop)
|
||||||
|
return True
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def info(self, request):
|
async def info(self, request):
|
||||||
@@ -106,6 +119,10 @@ class APIAddons(object):
|
|||||||
ATTR_BUILD: addon.need_build,
|
ATTR_BUILD: addon.need_build,
|
||||||
ATTR_NETWORK: addon.ports,
|
ATTR_NETWORK: addon.ports,
|
||||||
ATTR_HOST_NETWORK: addon.network_mode == 'host',
|
ATTR_HOST_NETWORK: addon.network_mode == 'host',
|
||||||
|
ATTR_PRIVILEGED: addon.privileged,
|
||||||
|
ATTR_DEVICES: self._pretty_devices(addon),
|
||||||
|
ATTR_LOGO: addon.with_logo,
|
||||||
|
ATTR_WEBUI: addon.webui,
|
||||||
}
|
}
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
@@ -182,8 +199,18 @@ class APIAddons(object):
|
|||||||
addon = self._extract_addon(request)
|
addon = self._extract_addon(request)
|
||||||
return await asyncio.shield(addon.restart(), loop=self.loop)
|
return await asyncio.shield(addon.restart(), loop=self.loop)
|
||||||
|
|
||||||
@api_process_raw
|
@api_process_raw(CONTENT_TYPE_BINARY)
|
||||||
def logs(self, request):
|
def logs(self, request):
|
||||||
"""Return logs from addon."""
|
"""Return logs from addon."""
|
||||||
addon = self._extract_addon(request)
|
addon = self._extract_addon(request)
|
||||||
return addon.logs()
|
return addon.logs()
|
||||||
|
|
||||||
|
@api_process_raw(CONTENT_TYPE_PNG)
|
||||||
|
async def logo(self, request):
|
||||||
|
"""Return logo from addon."""
|
||||||
|
addon = self._extract_addon(request, check_installed=False)
|
||||||
|
if not addon.with_logo:
|
||||||
|
raise RuntimeError("No image found!")
|
||||||
|
|
||||||
|
with addon.path_logo.open('rb') as png:
|
||||||
|
return png.read()
|
||||||
|
@@ -6,7 +6,8 @@ import voluptuous as vol
|
|||||||
|
|
||||||
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_DEVICES, ATTR_IMAGE, ATTR_CUSTOM)
|
ATTR_VERSION, ATTR_LAST_VERSION, ATTR_DEVICES, ATTR_IMAGE, ATTR_CUSTOM,
|
||||||
|
CONTENT_TYPE_BINARY)
|
||||||
from ..validate import HASS_DEVICES
|
from ..validate import HASS_DEVICES
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@@ -79,7 +80,7 @@ class APIHomeAssistant(object):
|
|||||||
return await asyncio.shield(
|
return await asyncio.shield(
|
||||||
self.homeassistant.restart(), loop=self.loop)
|
self.homeassistant.restart(), loop=self.loop)
|
||||||
|
|
||||||
@api_process_raw
|
@api_process_raw(CONTENT_TYPE_BINARY)
|
||||||
def logs(self, request):
|
def logs(self, request):
|
||||||
"""Return homeassistant docker logs.
|
"""Return homeassistant docker logs.
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ import voluptuous as vol
|
|||||||
from .util import api_process_hostcontrol, api_process, api_validate
|
from .util import api_process_hostcontrol, api_process, api_validate
|
||||||
from ..const import (
|
from ..const import (
|
||||||
ATTR_VERSION, ATTR_LAST_VERSION, ATTR_TYPE, ATTR_HOSTNAME, ATTR_FEATURES,
|
ATTR_VERSION, ATTR_LAST_VERSION, ATTR_TYPE, ATTR_HOSTNAME, ATTR_FEATURES,
|
||||||
ATTR_OS)
|
ATTR_OS, ATTR_SERIAL, ATTR_INPUT, ATTR_DISK, ATTR_AUDIO)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -19,11 +19,12 @@ SCHEMA_VERSION = vol.Schema({
|
|||||||
class APIHost(object):
|
class APIHost(object):
|
||||||
"""Handle rest api for host functions."""
|
"""Handle rest api for host functions."""
|
||||||
|
|
||||||
def __init__(self, config, loop, host_control):
|
def __init__(self, config, loop, host_control, hardware):
|
||||||
"""Initialize host rest api part."""
|
"""Initialize host rest api part."""
|
||||||
self.config = config
|
self.config = config
|
||||||
self.loop = loop
|
self.loop = loop
|
||||||
self.host_control = host_control
|
self.host_control = host_control
|
||||||
|
self.local_hw = hardware
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def info(self, request):
|
async def info(self, request):
|
||||||
@@ -58,3 +59,13 @@ class APIHost(object):
|
|||||||
|
|
||||||
return await asyncio.shield(
|
return await asyncio.shield(
|
||||||
self.host_control.update(version=version), loop=self.loop)
|
self.host_control.update(version=version), loop=self.loop)
|
||||||
|
|
||||||
|
@api_process
|
||||||
|
async def hardware(self, request):
|
||||||
|
"""Return local hardware infos."""
|
||||||
|
return {
|
||||||
|
ATTR_SERIAL: self.local_hw.serial_devices,
|
||||||
|
ATTR_INPUT: self.local_hw.input_devices,
|
||||||
|
ATTR_DISK: self.local_hw.disk_devices,
|
||||||
|
ATTR_AUDIO: self.local_hw.audio_devices,
|
||||||
|
}
|
||||||
|
@@ -63,9 +63,10 @@ class APISnapshots(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
def reload(self, request):
|
async def reload(self, request):
|
||||||
"""Reload snapshot list."""
|
"""Reload snapshot list."""
|
||||||
return asyncio.shield(self.snapshots.reload(), loop=self.loop)
|
await asyncio.shield(self.snapshots.reload(), loop=self.loop)
|
||||||
|
return True
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def info(self, request):
|
async def info(self, request):
|
||||||
|
@@ -6,11 +6,10 @@ import voluptuous as vol
|
|||||||
|
|
||||||
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_ADDONS, ATTR_VERSION, ATTR_LAST_VERSION, ATTR_BETA_CHANNEL,
|
ATTR_ADDONS, ATTR_VERSION, ATTR_LAST_VERSION, ATTR_BETA_CHANNEL, ATTR_ARCH,
|
||||||
HASSIO_VERSION, ATTR_ADDONS_REPOSITORIES, ATTR_REPOSITORIES,
|
HASSIO_VERSION, ATTR_ADDONS_REPOSITORIES, ATTR_LOGO, ATTR_REPOSITORY,
|
||||||
ATTR_REPOSITORY, ATTR_DESCRIPTON, ATTR_NAME, ATTR_SLUG, ATTR_INSTALLED,
|
ATTR_DESCRIPTON, ATTR_NAME, ATTR_SLUG, ATTR_INSTALLED, ATTR_TIMEZONE,
|
||||||
ATTR_DETACHED, ATTR_SOURCE, ATTR_MAINTAINER, ATTR_URL, ATTR_ARCH,
|
ATTR_STATE, CONTENT_TYPE_BINARY)
|
||||||
ATTR_BUILD, ATTR_TIMEZONE)
|
|
||||||
from ..tools import validate_timezone
|
from ..tools import validate_timezone
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@@ -41,42 +40,6 @@ class APISupervisor(object):
|
|||||||
self.host_control = host_control
|
self.host_control = host_control
|
||||||
self.websession = websession
|
self.websession = websession
|
||||||
|
|
||||||
def _addons_list(self, only_installed=False):
|
|
||||||
"""Return a list of addons."""
|
|
||||||
data = []
|
|
||||||
for addon in self.addons.list_addons:
|
|
||||||
if only_installed and not addon.is_installed:
|
|
||||||
continue
|
|
||||||
|
|
||||||
data.append({
|
|
||||||
ATTR_NAME: addon.name,
|
|
||||||
ATTR_SLUG: addon.slug,
|
|
||||||
ATTR_DESCRIPTON: addon.description,
|
|
||||||
ATTR_VERSION: addon.last_version,
|
|
||||||
ATTR_INSTALLED: addon.version_installed,
|
|
||||||
ATTR_ARCH: addon.supported_arch,
|
|
||||||
ATTR_DETACHED: addon.is_detached,
|
|
||||||
ATTR_REPOSITORY: addon.repository,
|
|
||||||
ATTR_BUILD: addon.need_build,
|
|
||||||
ATTR_URL: addon.url,
|
|
||||||
})
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
def _repositories_list(self):
|
|
||||||
"""Return a list of addons repositories."""
|
|
||||||
data = []
|
|
||||||
for repository in self.addons.list_repositories:
|
|
||||||
data.append({
|
|
||||||
ATTR_SLUG: repository.slug,
|
|
||||||
ATTR_NAME: repository.name,
|
|
||||||
ATTR_SOURCE: repository.source,
|
|
||||||
ATTR_URL: repository.url,
|
|
||||||
ATTR_MAINTAINER: repository.maintainer,
|
|
||||||
})
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def ping(self, request):
|
async def ping(self, request):
|
||||||
"""Return ok for signal that the api is ready."""
|
"""Return ok for signal that the api is ready."""
|
||||||
@@ -85,24 +48,30 @@ class APISupervisor(object):
|
|||||||
@api_process
|
@api_process
|
||||||
async def info(self, request):
|
async def info(self, request):
|
||||||
"""Return host information."""
|
"""Return host information."""
|
||||||
|
list_addons = []
|
||||||
|
for addon in self.addons.list_addons:
|
||||||
|
if addon.is_installed:
|
||||||
|
list_addons.append({
|
||||||
|
ATTR_NAME: addon.name,
|
||||||
|
ATTR_SLUG: addon.slug,
|
||||||
|
ATTR_DESCRIPTON: addon.description,
|
||||||
|
ATTR_STATE: await addon.state(),
|
||||||
|
ATTR_VERSION: addon.last_version,
|
||||||
|
ATTR_INSTALLED: addon.version_installed,
|
||||||
|
ATTR_REPOSITORY: addon.repository,
|
||||||
|
ATTR_LOGO: addon.with_logo,
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ATTR_VERSION: HASSIO_VERSION,
|
ATTR_VERSION: HASSIO_VERSION,
|
||||||
ATTR_LAST_VERSION: self.config.last_hassio,
|
ATTR_LAST_VERSION: self.config.last_hassio,
|
||||||
ATTR_BETA_CHANNEL: self.config.upstream_beta,
|
ATTR_BETA_CHANNEL: self.config.upstream_beta,
|
||||||
ATTR_ARCH: self.config.arch,
|
ATTR_ARCH: self.config.arch,
|
||||||
ATTR_TIMEZONE: self.config.timezone,
|
ATTR_TIMEZONE: self.config.timezone,
|
||||||
ATTR_ADDONS: self._addons_list(only_installed=True),
|
ATTR_ADDONS: list_addons,
|
||||||
ATTR_ADDONS_REPOSITORIES: self.config.addons_repositories,
|
ATTR_ADDONS_REPOSITORIES: self.config.addons_repositories,
|
||||||
}
|
}
|
||||||
|
|
||||||
@api_process
|
|
||||||
async def available_addons(self, request):
|
|
||||||
"""Return information for all available addons."""
|
|
||||||
return {
|
|
||||||
ATTR_ADDONS: self._addons_list(),
|
|
||||||
ATTR_REPOSITORIES: self._repositories_list(),
|
|
||||||
}
|
|
||||||
|
|
||||||
@api_process
|
@api_process
|
||||||
async def options(self, request):
|
async def options(self, request):
|
||||||
"""Set supervisor options."""
|
"""Set supervisor options."""
|
||||||
@@ -150,7 +119,7 @@ class APISupervisor(object):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api_process_raw
|
@api_process_raw(CONTENT_TYPE_BINARY)
|
||||||
def logs(self, request):
|
def logs(self, request):
|
||||||
"""Return supervisor docker logs.
|
"""Return supervisor docker logs.
|
||||||
|
|
||||||
|
@@ -9,7 +9,8 @@ import voluptuous as vol
|
|||||||
from voluptuous.humanize import humanize_error
|
from voluptuous.humanize import humanize_error
|
||||||
|
|
||||||
from ..const import (
|
from ..const import (
|
||||||
JSON_RESULT, JSON_DATA, JSON_MESSAGE, RESULT_OK, RESULT_ERROR)
|
JSON_RESULT, JSON_DATA, JSON_MESSAGE, RESULT_OK, RESULT_ERROR,
|
||||||
|
CONTENT_TYPE_BINARY)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -65,18 +66,23 @@ def api_process_hostcontrol(method):
|
|||||||
return wrap_hostcontrol
|
return wrap_hostcontrol
|
||||||
|
|
||||||
|
|
||||||
def api_process_raw(method):
|
def api_process_raw(content):
|
||||||
"""Wrap function with raw output to rest api."""
|
"""Wrap content_type into function."""
|
||||||
async def wrap_api(api, *args, **kwargs):
|
def wrap_method(method):
|
||||||
"""Return api information."""
|
"""Wrap function with raw output to rest api."""
|
||||||
try:
|
async def wrap_api(api, *args, **kwargs):
|
||||||
message = await method(api, *args, **kwargs)
|
"""Return api information."""
|
||||||
except RuntimeError as err:
|
try:
|
||||||
message = str(err).encode()
|
msg_data = await method(api, *args, **kwargs)
|
||||||
|
msg_type = content
|
||||||
|
except RuntimeError as err:
|
||||||
|
msg_data = str(err).encode()
|
||||||
|
msg_type = CONTENT_TYPE_BINARY
|
||||||
|
|
||||||
return web.Response(body=message)
|
return web.Response(body=msg_data, content_type=msg_type)
|
||||||
|
|
||||||
return wrap_api
|
return wrap_api
|
||||||
|
return wrap_method
|
||||||
|
|
||||||
|
|
||||||
def api_return_error(message=None):
|
def api_return_error(message=None):
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
"""Const file for HassIO."""
|
"""Const file for HassIO."""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
HASSIO_VERSION = '0.45'
|
HASSIO_VERSION = '0.49'
|
||||||
|
|
||||||
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')
|
||||||
@@ -44,6 +44,9 @@ JSON_MESSAGE = 'message'
|
|||||||
RESULT_ERROR = 'error'
|
RESULT_ERROR = 'error'
|
||||||
RESULT_OK = 'ok'
|
RESULT_OK = 'ok'
|
||||||
|
|
||||||
|
CONTENT_TYPE_BINARY = 'application/octet-stream'
|
||||||
|
CONTENT_TYPE_PNG = 'image/png'
|
||||||
|
|
||||||
ATTR_DATE = 'date'
|
ATTR_DATE = 'date'
|
||||||
ATTR_ARCH = 'arch'
|
ATTR_ARCH = 'arch'
|
||||||
ATTR_HOSTNAME = 'hostname'
|
ATTR_HOSTNAME = 'hostname'
|
||||||
@@ -63,12 +66,14 @@ ATTR_STARTUP = 'startup'
|
|||||||
ATTR_BOOT = 'boot'
|
ATTR_BOOT = 'boot'
|
||||||
ATTR_PORTS = 'ports'
|
ATTR_PORTS = 'ports'
|
||||||
ATTR_MAP = 'map'
|
ATTR_MAP = 'map'
|
||||||
|
ATTR_WEBUI = 'webui'
|
||||||
ATTR_OPTIONS = 'options'
|
ATTR_OPTIONS = 'options'
|
||||||
ATTR_INSTALLED = 'installed'
|
ATTR_INSTALLED = 'installed'
|
||||||
ATTR_DETACHED = 'detached'
|
ATTR_DETACHED = 'detached'
|
||||||
ATTR_STATE = 'state'
|
ATTR_STATE = 'state'
|
||||||
ATTR_SCHEMA = 'schema'
|
ATTR_SCHEMA = 'schema'
|
||||||
ATTR_IMAGE = 'image'
|
ATTR_IMAGE = 'image'
|
||||||
|
ATTR_LOGO = 'logo'
|
||||||
ATTR_ADDONS_REPOSITORIES = 'addons_repositories'
|
ATTR_ADDONS_REPOSITORIES = 'addons_repositories'
|
||||||
ATTR_REPOSITORY = 'repository'
|
ATTR_REPOSITORY = 'repository'
|
||||||
ATTR_REPOSITORIES = 'repositories'
|
ATTR_REPOSITORIES = 'repositories'
|
||||||
@@ -96,6 +101,10 @@ ATTR_TYPE = 'type'
|
|||||||
ATTR_TIMEOUT = 'timeout'
|
ATTR_TIMEOUT = 'timeout'
|
||||||
ATTR_AUTO_UPDATE = 'auto_update'
|
ATTR_AUTO_UPDATE = 'auto_update'
|
||||||
ATTR_CUSTOM = 'custom'
|
ATTR_CUSTOM = 'custom'
|
||||||
|
ATTR_AUDIO = 'audio'
|
||||||
|
ATTR_INPUT = 'input'
|
||||||
|
ATTR_DISK = 'disk'
|
||||||
|
ATTR_SERIAL = 'serial'
|
||||||
|
|
||||||
STARTUP_INITIALIZE = 'initialize'
|
STARTUP_INITIALIZE = 'initialize'
|
||||||
STARTUP_SYSTEM = 'system'
|
STARTUP_SYSTEM = 'system'
|
||||||
|
@@ -14,6 +14,7 @@ from .const import (
|
|||||||
RUN_CLEANUP_API_SESSIONS, STARTUP_SYSTEM, STARTUP_SERVICES,
|
RUN_CLEANUP_API_SESSIONS, STARTUP_SYSTEM, STARTUP_SERVICES,
|
||||||
STARTUP_APPLICATION, STARTUP_INITIALIZE, RUN_RELOAD_SNAPSHOTS_TASKS,
|
STARTUP_APPLICATION, STARTUP_INITIALIZE, RUN_RELOAD_SNAPSHOTS_TASKS,
|
||||||
RUN_UPDATE_ADDONS_TASKS)
|
RUN_UPDATE_ADDONS_TASKS)
|
||||||
|
from .hardware import Hardware
|
||||||
from .homeassistant import HomeAssistant
|
from .homeassistant import HomeAssistant
|
||||||
from .scheduler import Scheduler
|
from .scheduler import Scheduler
|
||||||
from .dock.supervisor import DockerSupervisor
|
from .dock.supervisor import DockerSupervisor
|
||||||
@@ -36,6 +37,7 @@ class HassIO(object):
|
|||||||
self.websession = aiohttp.ClientSession(loop=loop)
|
self.websession = aiohttp.ClientSession(loop=loop)
|
||||||
self.scheduler = Scheduler(loop)
|
self.scheduler = Scheduler(loop)
|
||||||
self.api = RestAPI(config, loop)
|
self.api = RestAPI(config, loop)
|
||||||
|
self.hardware = Hardware()
|
||||||
self.dock = docker.DockerClient(
|
self.dock = docker.DockerClient(
|
||||||
base_url="unix:/{}".format(str(SOCKET_DOCKER)), version='auto')
|
base_url="unix:/{}".format(str(SOCKET_DOCKER)), version='auto')
|
||||||
|
|
||||||
@@ -81,7 +83,7 @@ class HassIO(object):
|
|||||||
self.host_control.load, RUN_UPDATE_INFO_TASKS)
|
self.host_control.load, RUN_UPDATE_INFO_TASKS)
|
||||||
|
|
||||||
# rest api views
|
# rest api views
|
||||||
self.api.register_host(self.host_control)
|
self.api.register_host(self.host_control, self.hardware)
|
||||||
self.api.register_network(self.host_control)
|
self.api.register_network(self.host_control)
|
||||||
self.api.register_supervisor(
|
self.api.register_supervisor(
|
||||||
self.supervisor, self.snapshots, self.addons, self.host_control,
|
self.supervisor, self.snapshots, self.addons, self.host_control,
|
||||||
|
@@ -107,6 +107,7 @@ class DockerAddon(DockerBase):
|
|||||||
self.dock.containers.run(
|
self.dock.containers.run(
|
||||||
self.image,
|
self.image,
|
||||||
name=self.name,
|
name=self.name,
|
||||||
|
hostname=self.name,
|
||||||
detach=True,
|
detach=True,
|
||||||
network_mode=self.addon.network_mode,
|
network_mode=self.addon.network_mode,
|
||||||
ports=self.addon.ports,
|
ports=self.addon.ports,
|
||||||
@@ -144,7 +145,7 @@ class DockerAddon(DockerBase):
|
|||||||
try:
|
try:
|
||||||
# prepare temporary addon build folder
|
# prepare temporary addon build folder
|
||||||
try:
|
try:
|
||||||
source = self.addon.path_addon_location
|
source = self.addon.path_location
|
||||||
shutil.copytree(str(source), str(build_dir))
|
shutil.copytree(str(source), str(build_dir))
|
||||||
except shutil.Error as err:
|
except shutil.Error as err:
|
||||||
_LOGGER.error("Can't copy %s to temporary build folder -> %s",
|
_LOGGER.error("Can't copy %s to temporary build folder -> %s",
|
||||||
|
@@ -50,6 +50,7 @@ class DockerHomeAssistant(DockerBase):
|
|||||||
self.dock.containers.run(
|
self.dock.containers.run(
|
||||||
self.image,
|
self.image,
|
||||||
name=self.name,
|
name=self.name,
|
||||||
|
hostname=self.name,
|
||||||
detach=True,
|
detach=True,
|
||||||
privileged=True,
|
privileged=True,
|
||||||
devices=self.devices,
|
devices=self.devices,
|
||||||
|
87
hassio/hardware.py
Normal file
87
hassio/hardware.py
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
"""Read hardware info from system."""
|
||||||
|
import logging
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
|
||||||
|
import pyudev
|
||||||
|
|
||||||
|
from .const import ATTR_NAME, ATTR_TYPE, ATTR_DEVICES
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
ASOUND_CARDS = Path("/proc/asound/cards")
|
||||||
|
RE_CARDS = re.compile(r"(\d+) \[(\w*) *\]: (.*\w)")
|
||||||
|
|
||||||
|
ASOUND_DEVICES = Path("/proc/asound/devices")
|
||||||
|
RE_DEVICES = re.compile(r"\[.*(\d+)- (\d+).*\]: ([\w ]*)")
|
||||||
|
|
||||||
|
|
||||||
|
class Hardware(object):
|
||||||
|
"""Represent a interface to procfs, sysfs and udev."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
"""Init hardware object."""
|
||||||
|
self.context = pyudev.Context()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def serial_devices(self):
|
||||||
|
"""Return all serial and connected devices."""
|
||||||
|
dev_list = set()
|
||||||
|
for device in self.context.list_devices(subsystem='tty'):
|
||||||
|
if 'ID_VENDOR' in device:
|
||||||
|
dev_list.add(device.device_node)
|
||||||
|
|
||||||
|
return list(dev_list)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def input_devices(self):
|
||||||
|
"""Return all input devices."""
|
||||||
|
dev_list = set()
|
||||||
|
for device in self.context.list_devices(subsystem='input'):
|
||||||
|
if 'NAME' in device:
|
||||||
|
dev_list.add(device['NAME'].replace('"', ''))
|
||||||
|
|
||||||
|
return list(dev_list)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def disk_devices(self):
|
||||||
|
"""Return all disk devices."""
|
||||||
|
dev_list = set()
|
||||||
|
for device in self.context.list_devices(subsystem='block'):
|
||||||
|
if 'ID_VENDOR' in device:
|
||||||
|
dev_list.add(device.device_node)
|
||||||
|
|
||||||
|
return list(dev_list)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def audio_devices(self):
|
||||||
|
"""Return all available audio interfaces."""
|
||||||
|
try:
|
||||||
|
with ASOUND_CARDS.open('r') as cards_file:
|
||||||
|
cards = cards_file.read()
|
||||||
|
with ASOUND_DEVICES.open('r') as devices_file:
|
||||||
|
devices = devices_file.read()
|
||||||
|
except OSError as err:
|
||||||
|
_LOGGER.error("Can't read asound data -> %s", err)
|
||||||
|
return
|
||||||
|
|
||||||
|
audio_list = {}
|
||||||
|
|
||||||
|
# parse cards
|
||||||
|
for match in RE_CARDS.finditer(cards):
|
||||||
|
audio_list[match.group(1)] = {
|
||||||
|
ATTR_NAME: match.group(3),
|
||||||
|
ATTR_TYPE: match.group(2),
|
||||||
|
ATTR_DEVICES: {},
|
||||||
|
}
|
||||||
|
|
||||||
|
# parse devices
|
||||||
|
for match in RE_DEVICES.finditer(devices):
|
||||||
|
try:
|
||||||
|
audio_list[match.group(1)][ATTR_DEVICES][match.group(2)] = \
|
||||||
|
match.group(3)
|
||||||
|
except KeyError:
|
||||||
|
_LOGGER.warning("Wrong audio device found %s", match.group(0))
|
||||||
|
continue
|
||||||
|
|
||||||
|
return audio_list
|
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -27,8 +27,14 @@ def addons_update(loop, addons):
|
|||||||
if not addon.is_installed or not addon.auto_update:
|
if not addon.is_installed or not addon.auto_update:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if addon.version_installed != addon.version:
|
if addon.version_installed == addon.last_version:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if addon.test_udpate_schema():
|
||||||
tasks.append(addon.update())
|
tasks.append(addon.update())
|
||||||
|
else:
|
||||||
|
_LOGGER.warning(
|
||||||
|
"Addon %s will be ignore, schema tests fails", addon.slug)
|
||||||
|
|
||||||
if tasks:
|
if tasks:
|
||||||
_LOGGER.info("Addon auto update process %d tasks", len(tasks))
|
_LOGGER.info("Addon auto update process %d tasks", len(tasks))
|
||||||
|
Submodule home-assistant-polymer updated: 35c4e1d5ae...1aa387a72f
3
setup.py
3
setup.py
@@ -46,6 +46,7 @@ setup(
|
|||||||
'gitpython',
|
'gitpython',
|
||||||
'pyotp',
|
'pyotp',
|
||||||
'pyqrcode',
|
'pyqrcode',
|
||||||
'pytz'
|
'pytz',
|
||||||
|
'pyudev'
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"hassio": "0.45",
|
"hassio": "0.49",
|
||||||
"homeassistant": "0.49",
|
"homeassistant": "0.49.1",
|
||||||
"resinos": "0.8",
|
"resinos": "1.0",
|
||||||
"resinhup": "0.1",
|
"resinhup": "0.3",
|
||||||
"generic": "0.3",
|
"generic": "0.3",
|
||||||
"cluster": "0.1"
|
"cluster": "0.1"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user