stjohnjohnson / smartthings-mqtt-bridge

Bridge between SmartThings and MQTT
https://hub.docker.com/r/stjohnjohnson/smartthings-mqtt-bridge/
MIT License
363 stars 241 forks source link

Running MQTT Bridge on Raspberry Pi 3. #43

Open tjb8907 opened 8 years ago

tjb8907 commented 8 years ago

Ok so I thought I could figure this out on my own, with the help of a few of the write ups I've found, but I can't seem to make it work.

One of the write ups talking about it : [https://home-assistant.io/blog/2016/02/09/smarter-smart-things-with-mqtt-and-home-assistant/]

I am new to the RPi world, most of my projects have been Arduino so far. Anyway, I have successfully got Moqsuitto running on my Pi, and am trying to get the Bridge running, but am kind of lost. I have docker installed, and tried running the following.

Edit, the code didn't format this the same, but I did enter is as separate lines

$ docker run \ -d \ --name="mqtt-bridge" \ -v /opt/mqtt-bridge:/config \ -p 8080:8080 \ stjohnjohnson/smartthings-mqtt-bridge

The first time it went through and dowloaded a bunch of stuff but eventually gave an error

Error response from daemon: Cannot restart container mqtt-bridge: rpc error: code = 2 desc = "oci runtime error: exec format error"

I don't even know where to start troubleshooting. Am I way off on how to do this?

My end goal is to use MQTT with ESP8266's to talk to Smartthings. I think I will be able to figure that part out once I can get this working.

Thanks for the help, I'm trying to learn!

ethitter commented 8 years ago

The Docker images aren't ready for the Raspberry Pi. The "oci runtime error: exec format error" message relates to the absence of builds for the Pi's ARM processor.

Fortunately, I was able to get everything running on a Pi without Docker, using the instructions linked to from the blog post you noted. I started from the Raspbian Jessie Lite image.

First, install node 6 from nodesource:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install nodejs

After that, follow the node-only instructions for Mosca and the bridge. Be sure to include pm2, and follow its instructions to set it to run on startup: http://pm2.keymetrics.io/docs/usage/startup/. Use pm2 to start both Mosca and the bridge, which ensures the two will come up on a restart.

The bridge's config.yml will end up in your home directory (~/config.yml) in this scenario, which is where you'll need to set the IP of the broker. At this point, the MQTT broker and bridge should "just work," and you can proceed to the steps involving the SmartThings IDE.

One thing to note is that when you restart the Pi, the MQTT broker and bridge won't start before Home Assistant, so HA will seem to lose the MQTT-based things. Restart HA and everything comes back.

chilicheech commented 8 years ago

@ethitter There is a docker file for the Raspberry Pi: Dockerfile-rpi. You just have to build the image yourself. Here's how to build it: $ docker build -t smartthings-mqtt-bridge -f Dockerfile-rpi https://github.com/stjohnjohnson/smartthings-mqtt-bridge.git. Once built you can run it with $ docker run -d --name="mqtt-bridge" -v /opt/mqtt-bridge:/config -p 8080:8080 smartthings-mqtt-bridge.

Cheers,

ethitter commented 8 years ago

Haha, perfect; I never even noticed that.

cdrom1028 commented 5 years ago

It would be great to add to the install info a step by step on building a container for Raspberry Pi. There are a lot of gaps to fill to get this working.. Thanks to @chilicheech I got my Docker image up and running!