Smartthings MQTT Bridge

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.

Uhm… for Classic Smart App do you mean this https://play.google.com/store/apps/details?id=com.smartthings.android&hl=en&rdid=com.smartthings.android?
I’ve already installed the SmartThings app by Samsung, and in this app I’m able to see the device created on the smarthing.com website following the preocedure described here https://github.com/stjohnjohnson/smartthings-mqtt-bridge.
But I can’t understand what you mean for MQTT-BRIDGE-APP .

Installed the SmartThing app, bit I didn’t find MQTT_BRIDGE_APP in the “automatico - smartapp” section… Where I’m wrong?

I have everything set up on the ST side and it is communicating updates to my SmartThings-Mqqt bridge Add-on for HASSIO. I have the following config for my the Smartthings MQTT Bridge"

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

and using the Mosquitto MQTT Broker addon with the following settings:

{
  "plain": true,
  "plain_websockets": false,
  "ssl": false,
  "ssl_websockets": false,
  "anonymous": true,
  "logins": [],
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem"
}

My smartthings bridge shows the following in its log:

nfo: Saving current state
info: Saving current state
info: Subscribing to smartthings/Contacts/notify/cmd, smartthings/System/notify/cmd, smartthings/Front Door/battery/cmd, smartthings/Garage Door/battery/cmd, smartthings/Front Door/lock/cmd, smartthings/Garage Door/lock/cmd, smartthings/Clint's S8+/presence/cmd
info: Saving current state
info: Incoming message from SmartThings: smartthings/Garage Door/lock/state = unlocked
info: Saving current state

which indicates it is updating from the hub. But my Mosquitto log shows:

1532011746: mosquitto version 1.4.15 (build date 2018-03-04 15:14:46+0000) starting
1532011746: Config loaded from /etc/mosquitto.conf.
1532011746: Opening ipv4 listen socket on port 1883.
1532011746: Opening ipv6 listen socket on port 1883.
1532011746: Warning: Mosquitto should not be run as root/administrator.
1532011746: New connection from 192.168.1.74 on port 1883.
1532011746: New client connected from 192.168.1.74 as mqttjs_664798b7 (c1, k10).
1532011756: New connection from 192.168.1.74 on port 1883.
1532011757: Socket error on client <unknown>, disconnecting.
1532011757: New connection from 192.168.1.74 on port 1883.
1532011757: New client connected from 192.168.1.74 as d6bd8c15-4de7-4c2a-8ba1-f4cf08f9df59 (c1, k60).
1532012494: Socket error on client mqttjs_664798b7, disconnecting.
1532012495: New connection from 192.168.1.74 on port 1883.
1532012495: New client connected from 192.168.1.74 as mqttjs_664798b7 (c1, k10).
1532013547: Saving in-memory database to /data/mosquitto.db.
1532015348: Saving in-memory database to /data/mosquitto.db.
1532017149: Saving in-memory database to /data/mosquitto.db.
1532018950: Saving in-memory database to /data/mosquitto.db.
1532020751: Saving in-memory database to /data/mosquitto.db.
1532022552: Saving in-memory database to /data/mosquitto.db.
1532024353: Saving in-memory database to /data/mosquitto.db.
1532026154: Saving in-memory database to /data/mosquitto.db.
1532027955: Saving in-memory database to /data/mosquitto.db.
1532029756: Saving in-memory database to /data/mosquitto.db.
1532031557: Saving in-memory database to /data/mosquitto.db.

indicating that it is receiving connections, probably from homeassistant and from my smartthings bridge, but not updating from the smartthings bridge. The unknown device disconnect may have something to do with it. I configured my homeassistant config.yaml as such:

mqtt:
  broker: 192.168.1.74
  port: 1883
  discovery: true
  discovery_prefix: smartthings
  
  - platform: mqtt
    name: Garage Door
    state_topic: "smartthings/Garage Door/lock/"
    command_topic: "smartthings/Garage Door/lock/"
    payload_lock: "LOCK"
    payload_unlock: "UNLOCK"
    optimistic: false
    retain: true

With these settings my lock shows up in the UI, but it always shows as unlocked. If I click the LOCK button it will change state in the UI and present me an UNLOCK button, which I can press to change back, but it never transmits the signal to the MQTT broker. Somewhere there is a disconnect, probably mainly between MQTT and the smartthings bridge, but I can’t find it for the life of me.

Edit: my setup is an Ubuntu 16.04 VM with HASSIO installed. The Ubuntu VM is running on Bhyve Hypervisor on a FreeNAS 11.4 installation. All IP addresses are DHCP reservations in my router so that there is no mistake in entering the proper network info, but they always keep the correct IPs.

You said you followed the steps on GitHub - stjohnjohnson/smartthings-mqtt-bridge: Bridge between SmartThings and MQTT
but step 5 says

  • Install the Smart App on the Smart App IDE using “Create via code”

and step 6 says

  • Configure the Smart App (via the Native App) with the devices you want to share and the Device Handler you just installed as the bridge

SmartThings has two apps. The new Samsung app and the older SmartThings App.
In iOS app store they are named SmartThings Classic (old version) and SmartThings (Samsung Connect) which is the new version. The new version is JUNK and I recommend avoiding it. This is one of the main reasons I am moving my devices over to HA from SmartThings.

You have to install the MQTT_BRIDGE_APP using the ide (ide.smartthings.com) and you then need to open the app in the SmartThings Classic (Not sure if it is named same on android) and configure it.