I just went through the process of migrating HA from a VM to a Raspberry Pi, which means I had to set up SmartThings integration again. It’s slightly different on a Pi due to the architecture so I figured I’d share the steps involved. Please keep in mind that these steps might be slightly different for other users depending on the mish-mash of instructions that are out there. The assumption is that you already have HA configured outside of the ST/MQTT requirements.
I’m running a clean build of Raspbian and installed HA on top of that using the virtualenv instructions. Please note that I don’t have most of these set to autostart at boot yet, so you’re on your own for figuring that out.
Step 1: Installing the SmartThings bridge.
This is what allows SmartThings and HA to speak via MQTT. I use the Docker method since it just works and I don’t have to worry about other dependencies.
First, install Docker from their repo. The build included in Raspbian is outdated.
curl -sSL https://get.docker.com | sh
I added the “homeassistant” user to the Docker group so I wouldn’t need to use sudo for Docker configuration. If you don’t add the user, just preface the Docker commands with “sudo” for them to work properly.
Next, you’ll need to rebuild the Docker instance of smartthings-mqtt-bridge. The default build does not seem to work. I didn’t really dig into it, but I’m guessing it’s due to architecture requirements.
docker build -t smartthings-mqtt-bridge -f Dockerfile-rpi https://github.com/stjohnjohnson/smartthings-mqtt-bridge.git
docker run -d --name="mqtt-bridge" -v /opt/mqtt-bridge:/config -p 8080:8080 smartthings-mqtt-bridge
You’ll then need to edit the file
/opt/mqtt-bridge/config.yml. Change the value
Host to include to IP address of your Pi, i.e. the IP on wlan0. I had issues trying to use localhost, but the actual IP worked every single time. For example:
Host 10.10.10.10 in the config.
At this point you need to restart the Docker instance:
docker restart mqtt-bridge
Step 2: Install the MQTT broker.
I use Mosquitto as the broker since I was having problems with the native HA broker. It’s in the Raspbian repo and works with minimal configuration.
sudo apt install mosquitto
You then need to change a few settings. I did this by with
sudo vi /etc/mosquitto/conf.d/99-local.conf and adding the following entries to the file:
Please note that you’d want authentication if this is exposed to the Internet. Yes, anonymous isn’t the best security policy, but I’m not too concerned on my local network. You can then restart Mosquitto:
sudo service mosquitto restart
Step 3: Enable MQTT in HA.
There’s not much to this. Open up HA’s configuration.yaml file and add the following:
Please note that it’s safe to use “localhost” here, unlike the mqtt-bridge code.
Step 4: Enable SmartThings Integration.
The instructions for this are pretty complete, minus the Pi compatibility issues that I saw in the first steps. You just need the to follow the sections “SMARTTHINGS DEVICE” and “SMARTTHINGS APP” in the guide. Once you have the app enabled, you should start seeing MQTT events in the HA log.
Hope this helps!