Current state of MQTT on Smartthings- Hoping to be taught a bit on the subject (How to)

Hello all, hoping someone can help me understand a few things about MQTT potential within smarttthings. I am using a device that can be communicated to through MQTT. The device is called falcon pi player, it runs on a raspberry pi. The question I have is where do I begin with getting this running?

Essentially, my goal or starting goal is to be able to run a script (multiple mqtt commands) with a virtual switch within smartthings that starts the falcon pi player and sets it in repeat mode. The commands look like the below. When the switch is hit within the smartthings app, I would like it to show on and then after a few seconds go right back to off or a momentary switch would work also – because it is really only running a script so isn’t like a light or anything.

falconplayer_start_playlist:
sequence:
- service: mqtt.publish
data_template:
topic: albero/falcon/player/FPP/playlist/name/set
payload: “hassio”
- delay:
seconds: 1
- service: mqtt.publish
data_template:
topic: albero/falcon/player/FPP/set/playlist/start
payload: ‘1’
retain: false

I feel like I need these things (but I’ll be honest, this is all a guess because I have no clue what I’m doing): A mqtt broker like mosquitto running on a raspberry pi, and something on the smartthings side to take the button press (which I also don’t know how to make the button respond, or make a button in general)-- It would be nice if the device switches in my app which generally control a on/ off light could pretty much do the same thing for mqtt device I am speaking of.

I’m hoping all of this already exist as I don’t really want to recreate the wheel for what I am attempting to do. But I would be very appreciative if someone could help school me a little on how in the world to approach all of this or possibly a template I can review to make my own solution. Thank you all for any help that can be provided!!

First things first: do you have a SmartThings hub also, and if so, which model?

Hopefully you do and it’s one that can run edge Drivers, because that’s going to make this all a lot easier, I think.

EDGE DRIVERS

Not sure if @TAustin , Who has been doing some of the most creative integration work with edge drivers, has looked at MQTT integrations or not, yet.

HOME ASSISTANT

Outside of that, most of the people that I know who are using MQTT and smartthings are using home assistant as an intermediary, because home assistant has really good MQTT support. Here’s an example on that approach using the old architecture. So you might be able to set this up immediately, but it will stop working pretty soon because you’ll need to transition to the new architecture. But it will show you how home assistant might fit into the project.

Remember that in the past, people used groovy language DTH and smart apps and smartthings is going to pull the plug on those pretty soon. The replacement will be edge Drivers for the DTH and accessing the SmartThings API For the smart apps.

And just in case you need more information about edge:

NODE RED?

Other people have used node red, But I haven’t seen any project report on that in a long time and I know a couple of the Integrations, including the one using studio, seem to break over time. So to be honest I’m not sure where that option is right now, hopefully someone else will know.

Just remember that anything you find that is using Groovy will stop working pretty soon. you want to find things that use the new API or an Edge Driver instead.

(I know this post doesn’t really help, I just wanted to give you a few places to start researching. Hopefully someone will come along who has a current solution for the new architecture, and then I’ll just delete this. :sunglasses:)

Only superficially at this point. I guess I always expected that SmartThings would provide an official API for it in the Edge platform, but it looks like they are skipping it and moving directly to Matter (in fact there is already a socket.matter() method in the socket documentation).

If there is a big enough demand for it, I could look into doing an Edge library.

But honestly, for an app running on a Raspberry Pi that you want to interface with SmartThings, it seems a bit overkill. There are lots of options for integrating a Pi app with Smarthings, with perhaps the simplest being an http request interface between an Edge driver and the app.

If @Wtstreetglow’s device has other API options such as a RESTful API, that would be a much easier and quicker path.

1 Like

Hi JD,

Thank you for responding and being so helpful. You have helped me in the past and I am very thankful each time.

So, I have Smartthings v2. And I’m not going to lie, I haven’t kept up with the hardware situation very closely, so I don’t know the capabilities of my hub fully with regards to edge.

I was wandering if you were going to speak of home assistant. Since it is the case, now for a little story time. haha, lets just say, I got a little aggressive and found out the water is deep with regards to Home Assistant. I moved everything from smartthings over to home assistant because I didn’t want to use multiple “systems” and wanted control of everything in one spot.

At that time (less than a month or so ago), I was under the understanding that there really wasn’t much of a path for me with regards to sending mqtt commands from the smartthings app/ environment to the falcon pi player. This very well could’ve been determined through poor/ incomplete research. I am writing as I am concurrently reading your reply, so I think I’m getting ready to learn a hard lesson. (hopefully not)

Also, what you said, is exactly what I was wandering with regards to groovy/ soon to be past architecture. I felt like anything I potentially setup that relied on pre-edge software components would crash and burn as soon as the switches began getting flipped at smartthings. So, I have been in the weird state of flux with regards to integrating, essentially what it amounts to is a addressable rgb sign into my smartthings environment.

Thank you for the link you posted with regards to the potentially historic method of integrating HA and ST. I will have a look as education. I agree, I feel like it is possibly futile for me to go down that path.

Also, thank you for providing me with the edge link, all I currently know is that it is causing a good deal of heartburn amongst the community. But I will read the link you provided and get up to speed.

Node Red, yes, good ole node red. I had a run in with her one day. She was also not very kind to me but made pretty pictures.

I appreciate your honesty/ directness on this one. I felt the same. I did a good amount of reading/ research before I posted (but I won’t lie, some of this stuff get’s deep fast for me) and I was kind of left in the state of “well, it’s looking like this is not going to happen in ST based on the state of architecture etc.”-- I def wouldn’t want to put in a bunch of effort on setup and it being for nothing in 2 months time.

Essentially at this point, I’m just trying to come up with a good reason to get my devices back into ST from HA. It is more technical in that world than I thought it would be and some things that you would think would be simple are a nightmare in that environment but I do see how powerful it would/ could be if you were a pro in/at it (HA that is ).

Thank you again @JDRoberts. Maybe we’ll see something developed when necessity strikes.

1 Like

EDITED:

Thank you for your response here @TAustin .I really don’t think there will be a huge demand for it but maybe I’m wrong, it definitely wouldn’t be my first time nor my last. Essentially, this was the only device that I couldn’t seem to get integrated within smartthings due to its communication protocol (mqtt) and then when I moved everything to HA, I found out quickly, that wasn’t my scene. So of course, now I’m over here whining trying to see if I have any other options. The grass was not greener on the other side per say.

Also, I’m not sure any of these links would help you but this is what I’m trying to work with:

I got to doing some reading on the above and it looks like the offer something called curl. Below is a code example.

#!/bin/sh
###########################################################

StartPlaylist.sh - Start a playlist on the local system

The Playlist will play once and then stop.

###########################################################

Edit this line to hold the playlist name in quotes

PLAYLISTNAME=“PUT YOUR PLAYLIST NAME HERE”

If you want to start on a specfic numbered entry in the playlist

then put the entry number inside the quotes on the line below

STARTITEM=""

fpp -P “${PLAYLISTNAME}” ${STARTITEM}

They also offer a Rest API I believe but I don’t have the least clue how to use it either. Below is the screenshot of the help page that I stumbled upon. So it looks like, my question has now shifted to, is it possible to use this to start the playlist with a momentary button within smartthings. Hmmmmm. I think this makes me happy but I’m not sure yet until an expert chimes in. Thank you all again! @JDRoberts @TAustin

1 Like

Assuming you take care of getting a broker (e.g. Mosquito) set up, I can take a look at getting one of the existing Lua- based MQTT libraries running on Edge. If I can get that working this may not be so hard to do.

I’m out of town for several days but will dig into this when I’m back.

1 Like

If you can figure out the REST API commands that you want to send (you can experiment using your browser or curl), then it might be an easy solution to use just my web requestor driver which can send any HTTP GET or POST request that you configure, and it can be triggered with a virtual button.

1 Like

I follow you. I feel confident I can get the broker portion working correctly as I have the sign working properly on HA at the moment. I ended up setting up a mqtt script for “on” (linked earlier) and for “stop_now". That was kind of my proof of concept once I got it working and took a breather from it. I’m starting to realize I wish I would’ve came here for conversation before went nuclear on smartthings. Thank you all for being helpful and at least considering options with me. No problem on the out of town thing. I just appreciate you being willing to potentially use your expertise to help.

I do know the 2-3 rest api commands that I want to send. It looks like their help document gives an example of every single one.

I don’t really understand how to use the browser to send them but I will try to look it up and figure it out. (This seems odd to me because it is an internal network device and not cloud connected to my knowledge, a question will come shortly revolving around this, maybe there’s a port I forward to communicate with it from off network?)

The web request driver you speak of sounds like a potentially quick solution for communicating with this sign. Would you or anyone here have links to a “how to”. One thing that immediately comes to my mind is, would the web request concept work when away from home (I.e) would I have to open ports/ port forward etc like I have had to on HA?) I’m sorry for the weird questions, the topics/ details of the things we’re discussing are all new to me.

And lastly, And I’m sure you’ve already thought about this, I’m positive the Mqtt libraries your considering helping with will get more use from others rather than the rest api approach I may attempt if I can get ahold of some more resources/ how to (just to learn/ tinker for me). In the end, I would end up using most probably your professionally built solution.

Thank you @TAustin @JDRoberts for communicating like you do. I can already tell how helpful you all are for everyone here, both from technical prowess and a historical understanding of the SmartThings platform in general. Very appreciated.

1 Like

Just so you know…

Using a browser to send a message to a locally connected device is a common procedure used long before so much moved to the internet. :sunglasses:

If you’ve ever set up a router at home you probably did this. You had to connect the router locally by cable, then type its IP address (a long string of numbers and dots) into the browser and voila! Your computer was talking to the router over a local connection. No internet yet because it’s the router that’s going to establish internet connection AFTER it’s set up.

From a typical ASUS setup manual:

Connect the router’s LAN port to your PC’s LAN port with an Ethernet cable. 1. Enter your router’s IP address in the browser of your device . If you cannot find the IP address, type: http://router.asus.com in your browser for ASUS router models

Once you have a WiFi router set up, you can usually do the same thing for WiFi devices. (Annoyingly the SmartThings WiFi mesh router model requires an active internet connection to operate, but most WiFi routers don’t.)

Anyway, communicating locally is common for many kinds of devices. You just need to know the IP address of the device and the exact format of each command you’re going to send/receive.

@TAustin has been doing some amazing work in this regard with Edge Drivers, a real contribution to the community. :tada:

You just need to know the device’s IP and port address. Then just type something like this into your browser’s address bar while you are connected to your home network:

http://192.168.1.123:8000/api/playlist/my_playlist_name/start

This does an http ‘GET’ request.

If your device requires it, use ‘https:’ instead of ‘http:’

1 Like

Ahh, I see, I never really thought about it the way you explained it. I follow you conceptually.

Yeah, that’s strange on the smartthings router, really strange.

Good deal, well I definitely know the exact format of each command, luckily the help guide shows an example of each one.

And I agree with you on @TAustin, he seems very talented and very helpful to many people.

I am going to see if I can find enough resources on the smartthings side to figure out how to create a virtual switch that can send one of these rest commands to the sign. Or even better would be a device that when I go into the device screen on the app would give me 5-6 buttons and each button would send a different command by rest to the sign. (Maybe like “on”, “off”, “next”, “previous”, “set playlist”, and “repeat”. If I can get those, I will be happy.

I don’t think I would call it a “virtual switch,“ but there is an edge Driver (from @TAustin , unsurprisingly :wink:) that should let you send the local commands one at a time. It’s a little glitchy right at the moment because of some changes smartthings made (all of the edge architecture is still in beta, so every edge Driver need to be assumed to be in beta at this time), but he’s working on it.

As far as the kind of multi tile UI you’re talking about, to be honest, I don’t know what’s possible, hopefully someone else will respond or you may be able to ask in that thread and see what people have done.

Ahhh, I have been looking at that just a bit the last few days. I honestly believe that will be enough to accomplish the simple on/off I am going for. Just to make sure I am understanding the integration properly though.

So If I install the driver and then set up a few buttons that can send those 2-3 discrete commands, the button presses will only talk to the device if I am connected to my network/ Wi-Fi?

If I setup an automation with the command in the automation (if that’s possible, I believe I read it was), will that function properly?— I would assume so as the hub is connected to my home network?

Thank you for any clarification you can help me with on this. I know I’m getting a little bit detailed.

Yeah, hopefully, we can get a few responses on that concept with regards to the UI, even if e we would’ve been able to “stay the course” with the original concept in terms of using mqtt, I would’ve liked the same UI concept/ automation abilities.

Thank you @JDRoberts and @TAustin again for the conversation.

1 Like

Quick update on the subject of MQTT-based device integrations: Although I’m helping @Wtstreetglow with a RESTful API-based solution for his immediate needs, I’ve started working on an MQTT solution for the Edge environment. I have found an all-Lua implementation of an MQTT client and am working on retro-fitting it to work in the Edge platform. I’ve already successfully published and subscribed to MQTT topic messages to/from an Edge test driver. However there’s much work to do to make this a robust solution.

I’d like to hear from anyone that has an MQTT device to better understand the various requirements there may be. I don’t know that there can ever be a “generic” MQTT driver per se, but rather with an enabling library of code, we will be able to build custom Edge drivers to support MQTT device integration.

2 Likes

I know @mwav3 is now primarily working with another platform, but he did a lot with MQTT in the past and might have some thoughts.

I think @Automated_House might have something more current.

Also, @KasperT00 was trying to get an MQTT/ST bridge working earlier this year, but I think ended up abandoning the project. He wanted to bring some enocean devices into smartthings, if I remember correctly.

I have an MQTT driver for anyone that wants to experiment a bit with MQTT on Edge.

This driver will create a device that will allow you to configure it with an MQTT broker address (IP only, no port), a topic to subscribe to, and optionally, a topic to publish back out whatever it receives. It’s enough to prove that things are working between Edge and an MQTT broker (like Mosquitto).

I’ve put it on my test channel, where you can install it: MQTT Test Driver 1, version 2022-06-07T23:08:13.079753516

Once you Scan nearby devices to get the device created, go into settings and configure the broker IP address and the MQTT topic to subscribe to. If you want the driver to echo messages it receives to another topic, you can enter a publish topic as well.

Then back on the device Controls screen, press the Refresh button and any received messages will be shown in the HTTP Response Data field (ignore the HTTP name, I’m borrowing this field from another device!).

Depending on the frequency of published messages, they can sometimes come fast and furious, so often you’ll only see the latest displayed. But sometimes you can open history and see more. If you have a very high frequency of received messages you could start exceeding SmartThing platform limits on state updates, so it’s possible some could get lost.

If you want to change the subscribe or publish topic in Settings, you’ll have to press Refresh after they are saved to re-establish things with the broker.

I’ve tested this with Mosquitto, but no other brokers. I’ve only tested the most basic functionality so far, no authentication or other optional MQTT parameters.

1 Like

I’ll give this a go. I will be using Mosquitto also.

Would this be the same concept as the http call driver?— if you want to publish/ subscribe to additional topics, duplicate the device. Or is that not possible just yet.— And when it gets a step further, will all of the additional subscribe/ publish topics happen under 1 device or will one create duplicate devices for additional topics.

EDIT: Or, this is proof of concept first, looking for bugs, and then extend functionality in the future?

Sorry for the weird questions, I am new to a good amount of these things.

1 Like

Not yet. I don’t know if it would be useful to have something like an MQTT version of Web Requestor… Maybe, if there are enough cases where a routine could be created to key off of a specific MQTT message.

Yes, this is mainly an initial proof of concept for now to spur exactly those kinds of questions and to get the creative juices flowing for those with devices spitting out MQTT messages.

1 Like

@TAustin are you familiar at all with the HA MQTT Discovery protocol? It would be amazingly cool to see an MQTT Edge Driver “controller” that subscribes to the discovery topic, and then, like the virtual device drivers, can auto discover and configure MQTT devices. Such a driver could unlock a ton of potential from a single driver (rather than a shared lib/reference pattern).