Tutorial: Creating your first add-on

I’ve added a tutorial to the website to show you how to create a new add-on locally.

https://home-assistant.io/hassio/addon_tutorial/

5 Likes

Thanks for this ! Makes things a lot clearer !

Only thing missing : where to create that hello_world folder :wink:

“we first need access to where Hass.io looks for local add-ons” -> better with the actual path, or the way to find it :slight_smile:

What’s the point of addons? Why would I want an addon vs an appdaemon? Are addons GUI wrappers to Linux packages?

Read about Hass.io and I think it will become clear to you.

Addons allow you to easily add functionality that’s way more complex than what you can do with appdaemon. There could be an InfluxDB+Grafana add-on that gives you a working database plus nice graphs with just a few clicks and no shell-work at all. Or Mopidy + Snapcast. Or Or Or… It’s targeted at people that want great functionality without getting their fingers too dirty.

1 Like

I have been trying to go through the tutorial for creating an add-on step-by-step and for the life of me, I cannot get the add-on to show up in the Local Add-Ons panel.

There is an “OOPS” section in the tutorial that is not helping me fix my problem. I get no errors in the logs (no idea what a “supervisor panel” is), and as far as the files go, I copied and pasted from directly from the tutorial. Here is my files structure:

I’d like to point out that the image of the file structure shown on the tutorial has the “run.sh” file only as “run”. SO I tried renaming mine to that, but that did not work either.

Could use a bit of help. Thanks.

Did you hit the refresh button on the top right? If you don’t see anything, go check the supervisor logs in advanced settings, maybe some malformed json

Thanks for the reply. I did and also restarted a few times. The JSON was cut and pasted and run through jasonlint.com without error.
There is nothing in the Info logs, and if you mean the hassio homeassistant logs from the CLI, I don’t see anything wrong there. I searched the logs on words like “error”, “hello”. “json”, etc. …nothing.
As far as “supervisor logs”, I have no knowledge of those.

I’ m sorry I didn’t mention I’m running Hass.io. Perhaps that is why I don’t see a supervisor panel?

I can help with finding the logs. In HassIO the supervisor panel is accessed by going to Hass.io menu. Click in the top right corner (often the icon is not there as it keeps coming and going for me, but it still works) Select Advanced Settings from the drop down menu. You will then see Supervisor, Host OS and Home Assistant. Click on View Logs under Supervisor.

1 Like

Thank you Andyp85. I searched the community forum and home assistant website for “supervisor” and the only results had to do with Docker mostly. Now because of your post, perhaps something will come up next time someone wants to find information about it.

So I got the following error several times:

17-08-03 17:37:07 WARNING (MainThread) [hassio.addons.data] Can’t read /data/addons/local/hello_world/config.json

It looks like the local add-on system is looking for those add-ons in a directory called “data”. With Hass.io, the top-most directory I have access to with Samba is “addons”. I can’t navigate to the /data/ directory.

Any help there?

I noticed from the error message above that the system was looking for my add-on at

/data/addons/local/hello_world/config.json

Notice the /local/? That was not in the turoial, so I took a shot and added it and moved my addon to look like the error.
Funny error response. It added another /local/! :slight_smile:

17-08-04 17:57:38 WARNING (MainThread) [hassio.addons.data] Can’t read /data/addons/local/local/hello_world/config.json

Can’t seem to win.

I tried to create an add-on too by only renaming the add-on, but get the following error:

17-09-30 06:42:52 INFO (SyncWorker_15) [hassio.dock.addon] Start build local/armhf-addon-carwings:0.1
17-09-30 06:42:52 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 422, in start
    resp = yield from self._request_handler(request)
  File "/usr/lib/python3.6/site-packages/aiohttp/web.py", line 306, in _handle
    resp = yield from handler(request)
  File "/usr/lib/python3.6/site-packages/hassio/api/util.py", line 31, in wrap_api
    answer = await method(api, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/hassio/api/addons.py", line 171, in install
    addon.install(version=version), loop=self.loop)
  File "/usr/lib/python3.6/site-packages/hassio/addons/addon.py", line 443, in install
    if not await self.docker.install(version):
  File "/usr/lib/python3.6/site-packages/hassio/dock/util.py", line 18, in wrap_api
    return await method(api, *args, **kwargs)
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/hassio/dock/addon.py", line 192, in _install
    return self._build(tag)
  File "/usr/lib/python3.6/site-packages/hassio/dock/addon.py", line 205, in _build
    image = self.docker.images.build(**build_env.get_docker_args(tag))
  File "/usr/lib/python3.6/site-packages/docker/models/images.py", line 175, in build
    raise BuildError(chunk['error'])
docker.errors.BuildError: Please provide a source image with `from` prior to commit

The error message says little to me towards helping to resolve it. Does anyone know what I should do?

I also tried to follow the tutorial to create the simple “hello world” add on, but got the same error. Think it has something to do with the last line in the log, but no idea what to do from here.

17-10-01 03:31:12 INFO (SyncWorker_0) [hassio.dock.addon] Start build local/armhf-addon-hello_world:1
17-10-01 03:31:12 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 422, in start
    resp = yield from self._request_handler(request)
  File "/usr/lib/python3.6/site-packages/aiohttp/web.py", line 306, in _handle
    resp = yield from handler(request)
  File "/usr/lib/python3.6/site-packages/hassio/api/util.py", line 31, in wrap_api
    answer = await method(api, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/hassio/api/addons.py", line 171, in install
    addon.install(version=version), loop=self.loop)
  File "/usr/lib/python3.6/site-packages/hassio/addons/addon.py", line 443, in install
    if not await self.docker.install(version):
  File "/usr/lib/python3.6/site-packages/hassio/dock/util.py", line 18, in wrap_api
    return await method(api, *args, **kwargs)
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/hassio/dock/addon.py", line 196, in _install
    return self._build(tag)
  File "/usr/lib/python3.6/site-packages/hassio/dock/addon.py", line 209, in _build
    image = self.docker.images.build(**build_env.get_docker_args(tag))
  File "/usr/lib/python3.6/site-packages/docker/models/images.py", line 175, in build
    raise BuildError(chunk['error'])
docker.errors.BuildError: Please provide a source image with `from` prior to commit

Make sure that you’re running the latest version of the Hass.io host OS. You can update by going to advanced settings.

1 Like

Thanks that did the trick

:handshake:

Followed Tutorial and got
Can't build local/armhf-addon-hello_world:1 -> 500 Server Error: Internal Server Error ("Cannot locate specified Dockerfile: Dockerfile")

Got it to pop up, but when I press install it just gets red and nothing more happens

Hi,

I’m getting the same

docker.errors.BuildError: Please provide a source image with from prior to commit

error when i try to install a local add on i’m developing. I’ve read the tutorial and looked at the Dockerfiles of various addons but can’t figure out what i’m doing wrong. I’d much appreciate if someone could have a look at the Dockerfile, run.sh and config.json here:

I want to put more effort in polishing the addon, but i’d like to get it working on Hass.io in its basic form first.

@kdw2060, upgrade Docker on your host. You need to be at least on Docker 17.05.

1 Like