- Create an Add-on for Hass.io + Add-On Configuration
-
Add-ons are docker container they run a script and do some things. User are able to set a add-on specific options.
-Add-on folder
-addon_name:
+ Each add-on is stored in a folder. The file structure looks like this:
+addon_name/
Dockerfile
config.json
run.sh
-All add-ons are based on Alpine Linux 3.5. You can use FROM %%BASE_IMAGE%%
inside your docker file to build the right arch or for automatic build with our scripts.
-Your Docker need also a env variable VERSION
with the version of the add-on. With our build system include this line:
-ENV VERSION %%VERSION%%
+ Add-on script
+As with every Docker container, you will need a script to run when the container is started. A user might run many add-ons, so it is encouraged to try to stick to Bash scripts if you’re doing simple things.
+When developing your script:
+
+ /data
is a volume for persistent storage.
+ /data/options.json
contains the user configuration. You can use jq
inside your shell script to parse this data.
+
+echo '{ "target": "beer" }' | jq -r ".target"
-As a user might run many add-ons, it is encouraged to try to stick to Bash scripts if you’re doing simple things.
- Add-on config
+ Add-on Docker file
+All add-ons are based on Alpine Linux 3.5. Hass.io will automatically substitute the right base image based on the machine architecture. The Dockerfile is also required to have a VERSION environment variable which we will substitute with the version of the add-on.
+FROM %%BASE_IMAGE%%
+
+ENV VERSION %%VERSION%%
+ENV LANG C.UTF-8
+
+# Install requirements for add-on
+RUN apk add --no-cache jq
+
+# Copy data for add-on
+COPY run.sh /
+RUN chmod a+x /run.sh
+
+CMD [ "/run.sh" ]
+
+
+ Add-on config
+The config for an add-on is stored in config.json
.
{
"name": "xy",
"version": "1.2",
@@ -100,7 +121,7 @@
Options / Schema
-The options
dict have all available options with default value. If you want to set a value to requered and need to be set from user before it start the addon, set it to null. We support arrays for single deeps.
+The options
dict contains all available options and their default value. Set the default value to null
if the value is required to be given by the user before the add-on can start. Only non-nested arrays are supported.
{
"message": "custom things",
"logins": [
@@ -112,7 +133,7 @@
}
-The schmema
look like the options
but describe how we should validate the user input. For example above:
+The schema
looks like options
but describes how we should validate the user input. For example:
{
"message": "str",
"logins": [
@@ -132,10 +153,6 @@
email
url
- SSL
-Default you can use fullchain.pem
and privkey.pem
from /ssl
for you stuff. Your SSL addon should also create default this files.
- Need to know
-/data
is a volume with a persistant store. /data/options.json
have the user config inside. You can use jq
inside shell script to parse this data.