Create an Add-on for Hass.io


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:
  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%%

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

{
  "name": "xy",
  "version": "1.2",
  "slug": "folder",
  "description": "long descripton",
  "startup": "before|after|once",
  "boot": "auto|manual",
  "ports": {
    "123/tcp": 123
  },
  "map": ["config", "ssl", "addons", "backup"],
  "options": {},
  "schema": {},
  "image": "repo/{arch}-my-custom-addon"
}

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.

{
  "message": "custom things",
  "logins": [
    { "username": "beer", "password": "123456" },
    { "username": "cheep", "password": "654321" }
  ],
  "random": ["haha", "hihi", "huhu", "hghg"],
  "link": "http://blebla.com/"
}

The schmema look like the options but describe how we should validate the user input. For example above:

{
  "message": "str",
  "logins": [
    { "username": "str", "password": "str" }
  ],
  "random": ["str"],
  "link": "url"
}

We support:

  • str
  • bool
  • int
  • float
  • 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 known

/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.