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.
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") {
setLevel(Float.parseFloat(status));
}
else {
sendEvent(name: type, value: status)
}
}
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.
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.
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â: [
âsmartthings/Lamp/switchâ,
âsmartthings/Lamp/switchâ
],
4). Some times I got this error in ST MQTT bridge (10.0.0.18 is my SmartThings Hub):
error: Error from SmartThings Hub: Error: connect ETIMEDOUT 10.0.0.18:39500
error: {
âerrnoâ: âETIMEDOUTâ,
âcodeâ: âETIMEDOUTâ,
âsyscallâ: âconnectâ,
âaddressâ: â10.0.0.18â,
âportâ: 39500
}
error:
It looks like itâs somehow connected with âcallbackâ line in state.json file:
âcallbackâ: â10.0.0.18:39500â,
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?
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.
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âŠ
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?
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)
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.
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.
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.
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.
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.