I've been spending some time updating my home automation set up. I have a SmartThings hub with a few contact sensors and smart bulbs attached. It all worked fine but there were a few things I wanted to change and couldn't.

Firstly I'd tried writing a SmartThings app to integrate with Slack. Receiving updates was pretty straight-forward but issuing ad-hoc commands looked to be more fiddly.

Secondly I wanted to try and use some Sonoff switches to let me turn the LEDs in my kitchen on and off. It seemed like standard practice for these was to replace the firmware with the Tasmota firmware and then use MQTT.

I already had a Raspberry Pi running HomeBridge so that I could integrate SmartThings with the Apple Home app.

Installing mosquitto

So to start with I installed mosquitto, an open source MQTT broker. This was as simple as

sudo apt install -y mosquitto mosquitto-clients
sudo systemctl enable mosquitto.service

Having the clients installed on the Pi made it easier for testing but was not strictly necessary.

Setting up node-red

Again this was all as simple as following the instructions on the Node-RED website and running

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered

Then again set this up to run as a service using

sudo systemctl enable nodered.service

Setup Homebridge-node-red

Finally I had to connect the SmartThings hub to the MQTT broker. I was keen to keep HomeBridge in the picture for the moment as we use the Apple HomeKit integration. I tried a few different options and eventually settled on using a Node-RED plugin that integrates with HomeBridge.

This worked well. The only catch was that it is was necessary to configure the plugin and then do an inital deploy with no device selected in order to discover the devices.

Connect the devices to MQTT topics in Node-RED

Command topics

Having everything set up, the final job was to connect all the devices to MQTT topics.

This is straight forward in Node-RED.

Query topics

It's also easy to send messages to turn devices on or off when other devices change state. Here's the flow that turns various lights on and off when an associated door sensors change state.


Once you've got it working - and before you hook up too many devices - it is worth spending a little time thinking about how to organise your MQTT topics. Here's a summary of my MQTT topic strategy.