Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hassio addon #76

Merged
merged 11 commits into from
Sep 9, 2018
Merged

Hassio addon #76

merged 11 commits into from
Sep 9, 2018

Conversation

lnr0626
Copy link
Contributor

@lnr0626 lnr0626 commented Jul 19, 2018

I believe that this will work for serial PLMs, but not usb PLMs as is - hassio requires all mapped devices to be present, and so if users do not use a USB plm and we specify that /dev/ttyUSB0 (or w/e the device path is) should be mapped, the docker container will fail to start.

I added a script to build and push the docker containers, however we'll have to change the image repositories to something that makes sense.

To use it currently, users would have to copy the config.json into /addons/insteon-mqtt/config.json, add any device mappings the need (such as /dev/ttyUSB0), and install it from the local repo. Once the pip publishing/packaging stuff is done it would probably make sense to try to move this into the hassio community addons repo.

@TD22057
Copy link
Owner

TD22057 commented Jul 19, 2018

Thanks! There is something I'm not understanding though: why won't usb PLM's work? Aren't serial and usb basically both /dev devices? Wouldn't that be the same for both serial and usb devices? And don't people have to edit the config.yaml to point at their devices anyway? It might help if there were a set of instructions for hassio users for how to go about setting this up.

I'd prefer to not have these files at the top level. Having config.yaml and config.json in the same dir is going to be confusing. Perhaps a 'hassio' sub-directory? You can leave them as is for now - I can move them after merging.

Another question: Why copy from from /opt/insteon-mqtt to /config/insteon-mqtt in entrypoint.sh? Does that have any implication for the log and data file paths in config.yaml?

@lnr0626
Copy link
Contributor Author

lnr0626 commented Jul 20, 2018

I should have said I'm not sure if they'll work - it really depends on if the OS detects them as UART devices. I have the auto_uart setting to true, which is defined in the docs as:

Auto mapping all UART/Serial device from host into add-on.

So that might just work (especially if the USB PLMs are detected as ttyUSBx), however I can't verify that. I'll write up some instructions for setting this up and add them in.

For the file locations - I moved the config.json and entrypoint.sh, however the Dockerfile has to stay at the root because the context has to include the entire repo, otherwise I cannot copy it into the image.

Hassio uses /config/* as the location for configuration files - copying the default config.yaml into /config/insteon-mqtt/config.yaml is similar to what things like AppDaemon do. I believe that the data and log file paths are relative to the directory that insteon-mqtt is started in, not the directory that the config lives in. With the way the defaults are currently setup, it'll output logs to stdout and use /data/ as the data directory. Both of these are the correct defaults for hassio. The reason I copy the default config.yaml into /config/insteon-mqtt/config.yaml.default is because it'll allow easier comparisons and copy/paste if/when things are added into the config file.

@3nth
Copy link

3nth commented Aug 18, 2018

I've got this running with an Insteon PLM (2413U) in hassio. Only issue I ran into was the mqtt broker. New to hassio and wasn't obvious that the broker ip is 172.17.0.1 for the add-on.

Now to make it do things. I'll let you know if I find anything else.

@billchurch
Copy link

I have this working on hassio and a 2413U, so far so good.

@TD22057 TD22057 merged commit fa3bfff into TD22057:dev Sep 9, 2018
@TD22057
Copy link
Owner

TD22057 commented Sep 11, 2018

@lnr0626 what's the best way to remove the your user name from the docker file? I'm not a docker user so I could use some help. I'm guess I need to build those images and upload them myself every time I update the version number?

@lnr0626 lnr0626 deleted the hassio-addon branch September 12, 2018 03:13
@lnr0626
Copy link
Contributor Author

lnr0626 commented Sep 12, 2018

It should be decently straightforward. Do you have an account on dockerhub? And do you have docker installed on the machine you use for development?

Once you have those, you'll need to create 4 repositories in dockerhub (sorry, didn't know of a good way to automate this), the names are:

  • i386-insteon-mqtt
  • armhf-insteon-mqtt
  • amd64-insteon-mqtt
  • aarch64-insteon-mqtt

With that, you should be able to update this line and this line with your dockerhub username, log into dockerhub on your machine (docker login) and be good to go (./build-docker.sh should do the trick).

Let me know if you run into any issues, I'm happy to help.

@TD22057
Copy link
Owner

TD22057 commented Sep 15, 2018

Thanks. I installed docker-ce, created an account on dockerhub, built the 4 repos (https://hub.docker.com/u/td22057/), docker login worked, and then I tried to run the create script. When I do, I get these errors. Any ideas?

...
-----> Running preflight checks


 !     ERROR: Squashing images is only supported on a Docker daemon with experimental features enabled
The push refers to repository [docker.io/td22057/i386-insteon-mqtt]
An image does not exist locally with the tag: td22057/i386-insteon-mqtt
The push refers to repository [docker.io/td22057/i386-insteon-mqtt]
An image does not exist locally with the tag: td22057/i386-insteon-mqtt
The push refers to repository [docker.io/td22057/armhf-insteon-mqtt]
An image does not exist locally with the tag: td22057/armhf-insteon-mqtt
The push refers to repository [docker.io/td22057/armhf-insteon-mqtt]
An image does not exist locally with the tag: td22057/armhf-insteon-mqtt
The push refers to repository [docker.io/td22057/amd64-insteon-mqtt]
An image does not exist locally with the tag: td22057/amd64-insteon-mqtt
The push refers to repository [docker.io/td22057/amd64-insteon-mqtt]
An image does not exist locally with the tag: td22057/amd64-insteon-mqtt
The push refers to repository [docker.io/td22057/aarch64-insteon-mqtt]
An image does not exist locally with the tag: td22057/aarch64-insteon-mqtt
The push refers to repository [docker.io/td22057/aarch64-insteon-mqtt]
An image does not exist locally with the tag: td22057/aarch64-insteon-mqtt

@TD22057
Copy link
Owner

TD22057 commented Sep 15, 2018

I found the experimental tag on the server and got past that. Now I'm getting this error:

[aarch64] Processing /opt/insteon-mqtt
[aarch64] Could not install packages due to an EnvironmentError: [('/opt/insteon-mqtt/venv/lib64', '/tmp/pip-req-build-zwwjj4gw/venv/lib64', 
"[Errno 95] Not supported: '/tmp/pip-req-build-zwwjj4gw/venv/lib64'"), 
('/opt/insteon-mqtt/venv/bin/python', 
'/tmp/pip-req-build-zwwjj4gw/venv/bin/python', 
"[Errno 95] Not supported: '/tmp/pip-req-build-zwwjj4gw/venv/bin/python'"), 
('/opt/insteon-mqtt/venv/bin/python3', 
'/tmp/pip-req-build-zwwjj4gw/venv/bin/python3', 
"[Errno 95] Not supported: '/tmp/pip-req-build-zwwjj4gw/venv/bin/python3'")]
[aarch64] 
[aarch64] You are using pip version 10.0.1, however version 18.0 is available.
[aarch64] You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/sh -c pip3 install /opt/insteon-mqtt &&     chmod +x /opt/insteon-mqtt/hassio/entrypoint.sh' returned a non-zero code: 1
[aarch64]  !     ERROR: Docker build failed

@lnr0626
Copy link
Contributor Author

lnr0626 commented Sep 16, 2018

I've not seen that error before. I just double checked and the only setting I've customized is the experimental features (sorry about forgetting to mention that). My first thought would be to try updating pip - to do that, update the run command in the Dockerfile to:

RUN pip3 install --upgrade pip && \
    pip3 install /opt/insteon-mqtt && \
    chmod +x /opt/insteon-mqtt/hassio/entrypoint.sh

What OS are you working on? My second thought is it's something OS specific.

@TD22057
Copy link
Owner

TD22057 commented Sep 16, 2018

Thanks - no luck. Same error. I'm running Ubuntu 16.04LTS. I tried w/ my local insteon-mqtt venv active and without it active. I also tried running as su, removing my local /opt/insteon-mqtt, still get the same error.

@TD22057
Copy link
Owner

TD22057 commented Sep 16, 2018

Here is the whole output in case that helps:

---------------------------------------------------------
Community Hass.io Add-ons: Hass.io cross platform builder
---------------------------------------------------------
-----> Collecting information from Git
-----> Collecting information from Dockerfile
-----> Docker seems to be passed into the build env
-----> Docker is alive!
-----> Enabling cross compile features
Setting /usr/bin/qemu-aarch64-static as binfmt interpreter for aarch64 (arm)
Setting /usr/bin/qemu-arm-static as binfmt interpreter for arm (arm)
-----> Running preflight checks

NOTICE: Vendor not set!


NOTICE: Maintainer information is not set!

-----> Filling in configuration gaps with defaults

NOTICE: Disabled Docker cache, since squashing is enabled.

-----> Preparing Dockerfile for use
-----> Warming up cache for all requested architectures
-----> Warmup for all requested architectures finished
-----> Starting build of all requested architectures
[aarch64] -----> Running Docker build
[aarch64] -----> docker build --pull --tag td22057/aarch64-insteon-mqtt:0.6.3 --squash --build-arg BUILD_FROM=homeassistant/aarch64-base --no-cache --build-arg BUILD_ARCH=aarch64 --build-arg BUILD_DATE=2018-09-16T01:56:04Z
[aarch64] Sending build context to Docker daemon  40.51MB

[aarch64] Step 1/10 : ARG BUILD_FROM
[aarch64] Step 2/10 : FROM $BUILD_FROM
[aarch64] latest: Pulling from homeassistant/aarch64-base
[aarch64] Digest: sha256:6671862bfc5fc2a22e3e539ec8d264d8d643841088beee5f0ff1050c7c514627
[aarch64] Status: Image is up to date for homeassistant/aarch64-base:latest
[aarch64]  ---> c9b28a14a27f
[aarch64] Step 3/10 : ENV LANG C.UTF-8
[aarch64]  ---> Running in 1298e03bb35b
[aarch64] Removing intermediate container 1298e03bb35b
[aarch64]  ---> 28c2dbf13d84
[aarch64] Step 4/10 : RUN apk --no-cache add python3-dev
[aarch64]  ---> Running in 6adec452d885
[aarch64] fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/aarch64/APKINDEX.tar.gz
[aarch64] fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/aarch64/APKINDEX.tar.gz
[aarch64] (1/9) Installing pkgconf (1.5.3-r0)
[aarch64] (2/9) Installing libbz2 (1.0.6-r6)
[aarch64] (3/9) Installing expat (2.2.5-r0)
[aarch64] (4/9) Installing libffi (3.2.1-r4)
[aarch64] (5/9) Installing gdbm (1.13-r1)
[aarch64] (6/9) Installing xz-libs (5.2.4-r0)
[aarch64] (7/9) Installing sqlite-libs (3.24.0-r0)
[aarch64] (8/9) Installing python3 (3.6.6-r0)
[aarch64] (9/9) Installing python3-dev (3.6.6-r0)
[aarch64] Executing busybox-1.28.4-r0.trigger
[aarch64] OK: 90 MiB in 31 packages
[aarch64] Removing intermediate container 6adec452d885
[aarch64]  ---> f510a8f34c73
[aarch64] Step 5/10 : COPY . /opt/insteon-mqtt
[aarch64]  ---> 463b23010609
[aarch64] Step 6/10 : RUN pip3 install --upgrade pip &&     pip3 install /opt/insteon-mqtt &&     chmod +x /opt/insteon-mqtt/hassio/entrypoint.sh
[aarch64]  ---> Running in 314f48d4898c
[aarch64] Collecting pip
[aarch64]   Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)
[aarch64] Installing collected packages: pip
[aarch64]   Found existing installation: pip 10.0.1
[aarch64]     Uninstalling pip-10.0.1:
[aarch64]       Successfully uninstalled pip-10.0.1
[aarch64] Successfully installed pip-18.0
[aarch64] Processing /opt/insteon-mqtt
[aarch64] �[91mCould not install packages due to an EnvironmentError: [('/opt/insteon-mqtt/venv/lib64', '/tmp/pip-req-build-rpvbjgbn/venv/lib64', "[Errno 95] Not supported: '/tmp/pip-req-build-rpvbjgbn/venv/lib64'"), ('/opt/insteon-mqtt/venv/bin/python', '/tmp/pip-req-build-rpvbjgbn/venv/bin/python', "[Errno 95] Not supported: '/tmp/pip-req-build-rpvbjgbn/venv/bin/python'"), ('/opt/insteon-mqtt/venv/bin/python3', '/tmp/pip-req-build-rpvbjgbn/venv/bin/python3', "[Errno 95] Not supported: '/tmp/pip-req-build-rpvbjgbn/venv/bin/python3'")]
[aarch64] 
The command '/bin/sh -c pip3 install --upgrade pip &&     pip3 install /opt/insteon-mqtt &&     chmod +x /opt/insteon-mqtt/hassio/entrypoint.sh' returned a non-zero code: 1


[aarch64] �[0m !     ERROR: Docker build failed
The push refers to repository [docker.io/td22057/i386-insteon-mqtt]
An image does not exist locally with the tag: td22057/i386-insteon-mqtt
The push refers to repository [docker.io/td22057/i386-insteon-mqtt]
An image does not exist locally with the tag: td22057/i386-insteon-mqtt
The push refers to repository [docker.io/td22057/armhf-insteon-mqtt]
An image does not exist locally with the tag: td22057/armhf-insteon-mqtt
The push refers to repository [docker.io/td22057/armhf-insteon-mqtt]
An image does not exist locally with the tag: td22057/armhf-insteon-mqtt
The push refers to repository [docker.io/td22057/amd64-insteon-mqtt]
An image does not exist locally with the tag: td22057/amd64-insteon-mqtt
The push refers to repository [docker.io/td22057/amd64-insteon-mqtt]
An image does not exist locally with the tag: td22057/amd64-insteon-mqtt

@lnr0626
Copy link
Contributor Author

lnr0626 commented Sep 16, 2018

I'll spin up a VM and see if i can reproduce that error tomorrow. The things I'm seeing that it might be are if you're on a VM and using a shared folder (but it sounds like this isn't the case), or something with storage.

To help figure out what's going on, you can run this command in the insteaon-mqtt directory and it'll give you a shell into a container so you can run the commands interactively:

docker run --rm -it -v `pwd`:/opt/insteson-mqtt homeassistant/aarch64-base

One flag to add to the pip commands that might (but probably won't help) is the --no-cache-dir flag.

If that doesn't work, a possible workaround to try would be to switch to the vfs storage driver (steps are here: https://docs.docker.com/storage/storagedriver/vfs-driver/).

@TD22057
Copy link
Owner

TD22057 commented Sep 18, 2018

I tried the shell. I can create a venv, install the dependencies manually (pip install ...). But the moment I try to install insteon-mqtt, I get the same python3 error. Errno 95 is a socket endpoint error so I thought the VFS option might help but it doesn't change the result. Same error.

@lnr0626
Copy link
Contributor Author

lnr0626 commented Sep 20, 2018

What version of docker are you running?

@lnr0626
Copy link
Contributor Author

lnr0626 commented Sep 20, 2018

I'm not able to reproduce it in a vm :-(

@TD22057
Copy link
Owner

TD22057 commented Sep 22, 2018

Docker version 18.06.1-ce, build e68fc7a

tnt:~/git/insteon-mqtt: uname -a
Linux tnt 4.15.0-34-generic #37~16.04.1-Ubuntu SMP Tue Aug 28 10:44:06 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

tnt:~/git/insteon-mqtt: docker -v
Docker version 18.06.1-ce, build e68fc7a

Thanks for the attempt. I'm going to go back to the HA add on build instructions and try starting from scratch with those and see what happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants