I’d like to share some projects I’ve been working on that provide some nice integration options between SmartThings and other external applications. These use MQTT, which if you’re not familiar with, you can find plenty of information about on the internet. Put simply, you install what’s called an MQTT Broker application onto an always-on computer on your LAN (‘Mosquitto’ is one of the more popular free ones), and it provides a structured way to publish and subscribe to messages across devices and applications. This provides a nice solution to being able to get device information into, and out of SmartThings in a consistent and reliable way with little-to-no development expertise required.
MQTT solutions have existed for SmartThings on the ‘old’ Groovy-based platform. My new projects bring those capabilities onto the new Edge device and SmartApp execution platforms. I don’t profess to be the first to do this (@gol probably was!), but I’m offering these for general use.
UPDATED 11/16/22:
I’ve added an additional driver for creating SmartThings devices that have built-in MQTT support. Device types currently supported are acceleration sensor, alarm, battery, button, CO2 contact, dimmer, energy, fan, humidity, lock, motion, generic text or numeric, presence, robot, sound, switch, temperature, moisture, shade. It can also be used to publish any MQTT message to a given topic. The README file on github has all the details. Also see this post for latest info and this post for the initial announcement.
Simple MQTT message display device
To get started, this is a super-simple Edge driver that creates a device that can display MQTT messages for a given subscribed topic, and also echo those messages back out to another MQTT topic as a demonstration of the ability to also publish messages.
This is intended to be for simple testing and monitoring as you get your MQTT broker up and running, but it could also inspire you to imagine new ways to utilize this capability.
MQTT Handler/Discovery
This is also an Edge driver that can be considered a SmartThings implementation of Home Assistant’s ‘MQTT Discovery’ application. With this driver, you can literally create new SmartThings devices by publishing an MQTT message from anywhere on your LAN, and then update the states of those devices with additional MQTT messages. HA supposedly has many devices that support this framework, so this could provide a way to easily integrate HA devices into SmartThings.
MQTT SmartApp
This SmartApp provides a way to externalize any SmartThings device to MQTT. Use it to configure selected devices to send MQTT messages whenever their state changes. This provides a way to get device states to external applications without having to ‘poll’ the SmartThings RESTful API.
This SmartApp is designed to run on your own LAN - freeing yourself from Groovy or AWS-based SmartApps. The project is a demonstration on how to do that, and includes step-by-step setup instructions.
I offer these projects as starting points and am happy to revise/improve to meet community needs.
To install either of the Edge drivers, enroll your hub with my test channel and select these drivers to install to your hub.
Driver Name
--------------------
Simple MQTT message display MQTT Test Driver 1
MQTT Handler/Discovery MQTT Handler V1
Once available, you can use the mobile app to do an Add device / Scan for nearby devices and new MQTT devices will be created in your No Room Assigned room.
For the simple message display driver, all you need to do is go into device Settings and configure your broker address, optional authentication info, and a topic to subscribe to. It can be anything in the standard MQTT topic formats. Configure an optional publish topic if you also want received messages to be echoed out to another topic. After Settings are saved, tap the Refresh button on the Controls screen to connect to your broker, and messages received on the configured subscribe topic will be displayed.
For more information on the MQTT Handler/Discovery driver, please reference the README on github
For more information on the MQTT SmartApp, please reference the README on github
Thank you goes out to @jpeden @mwav3 and @fooktheta for providing early inspiration and feedback on these concepts.