jakeblatchford / neeo-homeassistant

A Home Assistant integration for NEEO
17 stars 4 forks source link

Dockerize #1

Open Decipher opened 7 years ago

Decipher commented 7 years ago

Hi @jakeblatchford,

Great work so far. I fully intend to get involved in some way (e.g., scratch my own itches) as I got my NEEO today and had already planned to spend some time over the holidays to tweak my home automation setup.

Unrelated stuff aside, to allow this service to run seamlessly I'd personally like to have it Dockerized so that I can run it on my NAS alongside HASS.

Happy to do the work, very minimal effort required, but just wanted to check if you had alternative plans, like actually having it run on the same container/service as HASS or anything similar?

jakeblatchford commented 7 years ago

@Decipher I've investigated dockerizing it and do have a Dockerfile, however I've not included it in the repository because I wasn't happy with some of the limitations I discovered. The main problem I found is that running avahi (for NEEO discovery) doesn't work in Docker without some special setup (see https://hub.docker.com/r/ianblenke/avahi/).

I believe if you skip the NEEO brain discovery step and use the ip of the brain instead you wouldn't need avahi.

e.g.

startSdkExample(brainIp);

instead of doing the normal

neeoapi.discoverOneBrain()

I'll test this out and if it works I'll add a Dockerfile and docker-compose.yml

I hadn't considered running it in the same container as HASS as I normally try to separate functionality out into separate containers. If you wanted it to be easy to use you'd probably want to retain brain discovery functionality.

Decipher commented 7 years ago

Hmm, interesting. I have used Avahi with Vagrant before but not with Docker. I'm surprised that it's needed to discover the brain, but my usage has only been around broadcasting of DNS.

As you say, it's need would be negated by hard coding the IP, but for some that may be a barrier of entry.... but then, it's unlikely that anyone that finds that a barrier of entry would be using Docker in the first place.

As I said, happy to help out, but I won't be free to do so for another week or two due to the time of the year.

jakeblat commented 7 years ago

Docker handles the networking differently so multicast traffic is not received (or even broadcast as far as I'm aware) by the container.

I've just tested using the brain ip directly instead of using the discovery function and although it appears to register I can't actually find the device when searching for it in the NEEO app.

For reference this is how I was testing:

docker run -it --rm --name=neeo-node -v /home/jake/containers/neeo-node/scripts:/scripts:rw -e BRAINIP=192.168.1.21 node:6 node /scripts/neeo-sdk-examples/lib/device/simpleAccessory/index.js

Running the same simpleAccessory script outside docker with the BRAINIP env set does work so it's definitely related to running it in a docker container.

Out of interest when you refer to Avahi in Vagrant were you using Docker as the provider or something else like VirtualBox? VirtualBox's networking will happily deal with multicast traffic.

vinteo commented 6 years ago

It would be great if you can dockerize it then it can be bundled as a hassio addon so users can just install it as an addon if they are using hass.io