SmartThings Community

MQTT Bridge [device + app]


(Jay S) #346

Found the file but I can not get MQTT bridge to talk to smartthings.
The command shows up in the logs but nothing changes


Where did you find the file?


I had to manually add entries again today as the subscriptions were never added to state.json.

I’m running npm on windows so it’s under C:\Users\<USERNAME>\AppData\Roaming\npm\node_modules\smartthings-mqtt-bridge on my machine.

You can search your entire filesystem for state.json if you are unsure of where it’s located.

(Carlos Ravelo) #349

The device handler has to be able to accept the value being sent from the bridge. In order to do that you either need to implement a command for setting the value, I had trouble with this. Or implement a command setStatus that looks like this:

def setStatus(type, status) {
    log.debug("Setting status ${type}: ${status}")
    // special handling for non-standard attributes
    if (type == "level") {
    else {
        sendEvent(name: type, value: status)

(Carlos Ravelo) #350

To refresh subscriptions go into the smart app and hit save without changing any settings. That will trigger a re-subscribe event on the bridge.


That’s the way it’s supposed to work. That’s the way it used to reliably work. I’ve saved the smartapp dozens of times since I’ve noticed the problem for the first time back in October and only one time had it update on its own. I let it sit for days one time and it never updated.

(Carlos Ravelo) #352

hmmm not sure what could be wrong then. Its been working great for me. Can you walk me through your setup with more details maybe I can figure it out. PM me if you want.

(Aleš Příhoda) #353

Hi guys… I am stuck for now…

1). Even after some hours trying I am not able to send anything to ST (node-red -> MQTT -> SmarThings). I can get working only reverse direction (SmarThings -> MQTT -> node-red). But in my case I am seeing all my commands from node-red in ST MQTT bridge just fine. Only SmartThings Hub (or SmartApp?) doesn’t do enything with my devices. No related errors in ST IDE. It seems that command is not received.

I got this when switch my lamp off:

info: Incoming message from SmartThings: smartthings/Lamp/switch = off
info: Incoming message from MQTT: smartthings/Lamp/switch = off
info: Skipping duplicate message from: smartthings/Lamp/switch = off

And this when fire up command from node-red:

info: Incoming message from MQTT: smartthings/Lamp/switch = off
info: Skipping duplicate message from: smartthings/Lamp/switch = off

2). I am running ST MQTT bridge without docker on the same machine (with raspbian) as mosquitto broker. ST Hub is located at the same local area network. Is network trafic from bridge forwarded over ST cloud or is it goes directly to Hub over local area network? What MAC address I should use in MQTT Device (MAC address of my raspbian machine or MAC address of my router connected to the internet)?

3). In my state.json file there are all my devices but all lines are doubled. Don’t know why. Is that normal?

“subscriptions”: [

4). Some times I got this error in ST MQTT bridge ( is my SmartThings Hub):

error: Error from SmartThings Hub: Error: connect ETIMEDOUT
error: {
“errno”: “ETIMEDOUT”,
“code”: “ETIMEDOUT”,
“syscall”: “connect”,
“address”: “”,
“port”: 39500

It looks like it’s somehow connected with “callback” line in state.json file:

“callback”: “”,

But TCP port 39500 is closed on my Hub. Why is bridge trying to connect to ST on closed port?

Can somebody confirm that ST MQTT bridge is working this way I am trying?

(Carlos Ravelo) #354

The bridge is working great for me. Please try adding a suffix to the state and/or commands to distinguish them. The Mac address is very important it should be set to the Mac address of the card in the machine where the bridge is running.

Not sure about the closed port communication.


I’m experiencing the same issue. Port scan shows my 39500 is open for me, though.

I see all the traffic going back and forth, but ST doesn’t do anything with the commands it receives from Home Assistant.

(Aleš Příhoda) #356

It is working now! I just restarted Hub remotely, port 39500 is now open and ST is responding as I expected… Nothing has changed in bridge logs… Except no errors are shown… Difficult to debug this state…

FYI when I change MAC address to non existant one it is working also… So it looks like correct MAC address is not needed.

dphoenix: Try to restart your ST Hub and we will see…

(Jeremy Laidman) #357

Hi. I’m trying to get ST<–>bridge<–>mosquitto<–>node-red. I don’t seem to be able to get any MQ messages past the bridge. If I subscribe to topic “#” I never see anything. The bridge log file doesn’t show any errors; just says “listening at http://localhost:8080” and occasionally “saving state”.

Even if I use mosquitto_pub to send a message, I see nothing in the events.log related to the message, or even a connection.

My ST IDE event log shows the following error, which I think is a different issue.

Field error in object 'physicalgraph.device.Device' on field 'deviceNetworkId': rejected value [B827EB4FF877]

Can anyone suggest a way to diagnose either of these problems?


Sadly, nothing. Lots of reboots. Reinstalled from scratch. Everything looks like it’s working. SmartThings just doesn’t execute the commands it’s given by HA.


@stjohn Thanks for the excellent solution! Recently I started using Amazon Dash button with smartthings-nodeproxy. It looks like there is some conflict if smartthings-mqtt-bridge runs at the same interface on the same machine as smartthings-nodeproxy, because only the MQTT Bridge SmartApp gets the button press event. Dash Button SmartApp from smartthings-nodeproxy won’t do anything with its selected switch. I can get around this issue by setting the IP & MAC addresses of the MQTT Bridge DTH to a different interface (say wifi vs. wired LAN). Do you know if there is a more appropriate solution or is this a limitation of SmartThings?

(Mike Coscia) #361

Hi guys, trying to get this bridge up and going but the ST app keeps throwing me an error. On initial install, I select my devices, select the bridge and hit save. A generic error pops up and it doesn’t save the settings. This error shows up in the logs…

Any ideas?

 7:40:42 PM: error org.springframework.transaction.TransactionSystemException: Could not roll back Hibernate transaction; nested exception is org.hibernate.TransactionException: JDBC rollback failed @line 532 (updateSubscription)

(Amauri Viguera) #362

I’ve gotten mine running and reinstalled a few times and it’s always something with the configuration.

Make sure you have the SmartApp installed, install the DTH and make sure that you use the MAC address of your device in uppercase with no colons – both when you edit the device and when you edit the preferences.

Then you should be able to install the device on the phone app and install the app with no issues.

(Mike Coscia) #363

I had colons in my MAC address, took them out and the app saved with no errors! Thanks, I would have never figured that out. However, devices did not show up in HA. Need to carefully go over the directions again.

(Amauri Viguera) #364

You have to define each individual item in HA as an mqtt sensor. It sucks because it’s tedious and there’s no way to just export something from ST or from the bridge config as a device, but that’s the way it is.

What I did was set up an include in the main config yaml for “sensors.yaml” then add each ST sensor into that one file with the ST topic. I’ve seen people include a folder and have individual files for each sensor as well.

(Mike Coscia) #365

Yeah I use folders with multiple sensor/switch files to keep things clean. I created a smartthings.yaml file in my sensor folder. However, I can’t figure out how to add them! I used this guide and it says to look for the name in the SmartThingsBridge log files. The log files are empty though. :confused:

(Amauri Viguera) #366

If the bridge is working at all, you should be able to use the IDE Live Logging and the MQTT broker log itself to see stuff happening – forget the bridge log.

The IDE should tell you the messages that are being sent and the broker log should show you whenever something changes.

I’d start with the IDE and see if there are any messages and work your way out from there.