Smartthings MQTT Bridge

Yes, you can use the MQTT bridge to send events via MQTT.

Not talking about “events” in general… I’m trying to determine what the current SmartThings MODE is set to (“Home”, “Away”, etc.) via HomeAssistant. I have not been able to find a definite answer or documentation on the proper config.

you can always create a virtual switch and use that

One switch? Wouldn’t I need separate on/off switches for each mode?

That approach can work, but it seems kinda clumsy vs having direct access to the current SmartThings mode.

You would need 1 per mode. Home assistant doesn’t necessarily have modes either. You would still need to program a way around it anyways. Your best bet if you really want modes is to look at the documentation and update it to support modes but the question is where will you assign the modes to? What ever component you decide to use you will need to make sure it supports MQTT. The switch idea may be a work around but will probably supply the fastest work around. You could even use those switches to switch modes if you wanted to.

With the ST cloud API out, I hope that we can get rid of the MQTT bridge completely and have a native integration.

@arsaboo MQTT may suck but the new API still requires a custom smartapp thus remaining in the cloud. So asides from being able to easily pull in devices there isn’t much more benefit than that right? I mean its not like it will run locally to be any faster than it is now right?

I agree…it is not a local solution, but definitely better then relying on MQTT. One step at a time :slight_smile:

2 Likes

Good Morning Everyone,
So last night I added the docker container that built out the whole HA environment for me. At first my docker container was on a diff subnet than where my ST lives at. But I added a new NIC to the VM that is hosting this docker container so that they’re now both on the same the subnet. The problem I’m having is that while ST is talking just fine to HA. I cannot for the life of me get HA to talk back to ST. I have one switch setup right now in HA and if it turns on from the ST side the switch registers that it was turned on and HA reflects it properly. But if I click on/off in HA nothing is ever sent back to ST. My only thought with this is that it could be that the box is still trying to send the packet out over the regular subnet and not this secondary one. Guess its time to do a little tracert and see what path it takes to get back to ST. In the mean time if anyone has any thoughts on this please let me know. Perhaps I’m missing something somewhere. BTW I followed the guides on this posted here at HA to get this whole thing setup and running.

UPDATE: so it is going out over the proper route to reach my ST hub if that is how this is designed to work.

Here is my config for the one light switch. Is it because I’m controlling the state of the switch?

switch:           
  platform: mqtt     
  name: "Garage Lights"                                              
  state_topic: "smartthings/Garage Lights/switch/state"
  command_topic: "smartthings/Garage Lights/switch/state"
  payload_on: "on"     
  payload_off: "off"                                                            
  retain: true  

UPDATE2: So it turns out I was using the wrong commands in my device to control the switch. I"m still learning :slight_smile:

switch:
  platform: mqtt
  name: "Garage Lights"
  state_topic: "smartthings/Garage Lights/switch/state"
  command_topic: "smartthings/Garage Lights/switch/cmd"
  payload_on: "on"
  payload_off: "off"
  retain: true

But the good news is that now its turning the lights on and off in my garage. Now to get the rest of my 60+ some odd devices in here. Don’t quite have a plan of what all I’m going to do with HA yet. But I do have some ideas

This thread is very helpful. Anyone in the future please note the smartthings-bridge and smartthings hub need to be in the same network. The bridge relies on a layer two connection.

question for someone who as a working mqtt smartthings and HA set up can you guys please share the settings in /etc/mosquitto/mosquitto.conf

You are a life-saver. Love you. :-):smiley:

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

allow_anonymous true
listener 1883
listener 9001
protocol websockets
user mosquitto
persistence true
persistence_file mosquitto.db
persistence_location /var/lib/mosquitto/
pid_file /var/run/mosquitto.pid

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

I’m trying to control a Samsung SmartThings device via Home Assistant. So far the two are communicating just fine as I can see in the MQTT logs on both sides. However I’m unable to figure out how to pass the required ‘name’ to SmartThings from Home Assistant. The ‘Value’ is being passed and is incorrect which is easily corrected, but the ‘name’ part is eluding me. This screenshot should make the problem more clear.

It would be better to show the mqtt message rather then the smartapp logs. Im sure that the message sent isnt recognized in HASS and the response isnt programed in the smartapp so ST cent recognize it. That was my problem with the fibaro RGBW controller.

I have MQTT working, ST connects to it and I can see the messages on both of my brokers (one set up just for ST, the other is my authenticated broker used for other mqtt devices).

in the MQTT Bridge config file I have:

mqtt:
    host: mqtt://st-mqtt:1883 # Don't worry about this, it works within Docker when using docker compose.
    preface: smartthings
    state_read_suffix: state
    state_write_suffix: set_state
    command_suffix: cmd

In HA config I have:
switch:
platform: mqtt
name: “Foot Rest”
state_topic: “smartthings/Foot Rest/switch/state”
command_topic: “smartthings/Foot Rest/switch/cmd”
payload_on: “on”
payload_off: “off”
retain: true

When I trigger the switch in the ST app, it switches the device and the state updates properly in HA.
When I try to trigger the switch from HA I see the mqtt message published (in this example to turn off):
2018-05-22T15:47:46.520Z - info: Incoming message from MQTT: smartthings/Foot Rest/switch/cmd = off

But it doesn’t trigger the switch, and the state in HA switches back to “on”. (The same happens if the state is off and I try to turn it on.)

UPDATE Found the solution about 1/2 way through this thread: Smartthings MQTT Bridge

remove the last “/state” and “/cmd” from topics and it will work fine

Hi all, I am struugling here with same symptons I am reading above…

I can get HA to show the status of the devices in Smartthings, changing my light from On to Off reflects in HA, but for the life of me I can’t get it to go the other way. I see NO mqqt messages in the Smartbridge logs (I am using Hass.io). So if I attempt to turn off my on light the switch goes back to ON within a few seconds and there is no activity on the logs

My mac address is definitely the correct Ethernet one, I am not using wireless.

I am literally running out of ideas here to try

Logs from smartthings-mqtt-bridge

starting version 3.2.2
info: Starting SmartThings MQTT Bridge - v1.3.4
info: Loading configuration
info: Loading previous state
info: Perfoming configuration migration
info: Saving current state
info: Connecting to MQTT at mqtt://192.168.0.189:1883
info: Configuring autosave
info: Configuring API
info: Listening at http://localhost:8080
info: Incoming message from SmartThings: smartthings/Speakers/switch/state = off
info: Incoming message from SmartThings: smartthings/Speakers/switch/state = on
info: Incoming message from SmartThings: smartthings/Lounge Window/battery/state = 100
info: Incoming message from SmartThings: smartthings/Speakers/switch/state = off
info: Incoming message from SmartThings: smartthings/Speakers/switch/state = on

I tried tu put a look in this huge thread, but I’m still confuse, so please… some good soul can help me to understand?
Well I running a well tested and 100% working MQTT bridge at address 192.168.1.80 and port 1883
I’ve installed the HASS.io SmartThingsBridge add-on and this is my config

{
  "broker_host": "192.168.1.80",
  "broker_port": 1883,
  "preface": "smartthings",
  "state_suffix": "state",
  "command_suffix": "cmd",
  "login": "***",
  "password": "***",
  "bridge_port": 2080
}

And following the wiki page of the add-in I’ve configured the device on the smartthings.com website, so I’ve this new device that can I see also in my smartphone app.

myDevice Device
Name	myDevice
Label	
Type	MQTT Bridge
Version	Published
Device Network Id	SH1
Status	ACTIVE
Last Activity At	2018-07-17 7:32 AM UTC
Date Created	2018-07-17 7:32 AM UTC
Last Updated	2018-07-17 8:40 AM UTC
Data	No data found for device
Current States	No states found
Preferences (edit)	
Name	Type	Value
ip	string	192.168.1.86
mac	string	B8:27:EB:44:1F:93
port	string	2080
Execution Location	Cloud
Events	List Events
In Use By	

The log of the add-on is the following…

starting version 3.2.2
info: Starting SmartThings MQTT Bridge - v1.3.4
info: Loading configuration
info: Loading previous state
info: Perfoming configuration migration
info: Saving current state
info: Connecting to MQTT at mqtt://192.168.1.80:1883
info: Configuring autosave
info: Configuring API
info: Listening at http://localhost:2080

But the smartphone app tell me that isn’t possible to connect to this device.

Other problem… tried to put this config as MQTT switch

  - platform: mqtt
    name: "my SmartThing Device"
    state_topic: "smartthings/mydevice/switch/state"
    command_topic: "smartthings/mydevice Lights/switch/cmd"
    payload_on: "on"
    payload_off: "off"
    retain: true   

… but when I try to commute this switch I see nothing on my MQTT broker.

@Fulvi_Igor
Did you install the MQTT-BRIDGE-APP and configure the devices you want to allow access to in the Classic Smart App? I didn’t see that in your list of steps.
Install the app and go to “Automation->SmartApps->MQTT-BRIDGE-APP” then select the devices you want to control in HA.