[OBSOLETE] MQTT Bridge [device + app]

just found this post and wanted to ask if MQTT Bridge would work for my situation. I do not use Home Assistant but I do have Smartthings controlling most of my house. I have a front door access system that I built that has an NFC reader connected to an ESP8266 and then sends the UID of the card to node-red for the logic. I did have node-red installed on a PI but I am wanting to switch over to running node-red on my mac mini which is now being used as a server. Here is where I am looking at MQTT-Bridge. I also have a Yale T1L touch screen deadbolt with z-wave. I was using a Z-stick Gen5 Zwave usb stick but I have always had trouble with it because it creates a 2nd z-wave network in my house and do to crosstalk sometimes unlocking the deadbolt fails. What I would like to do is have the system I built to monitor the front door still run thru my node-red server and do all the logic but have the deadbolt connected to Smartthings and have node-red tell Smartthings to lock or unlock the deadbolt. Is this something that MQTT-Bridge can do. To be forward and honest I am not a programmer and most of the stuff I do I fumble thru, fail a lot and then ask help from friends that are programmers.

Just wanted to let everyone know it now works once I deleted device handlers, smart apps, and devices and redid the smartthings IDE requirements if anyone else is facing the same issue.

I’m running into the same issue. Can you specify what requirements were incorrect for you?

Sorry if this is a dumb question:
Where do I add the mqtt user and password ?
I use PI 3 running HassIO in which I run the Mosquitto broker (Connection gets refused because there is no user and pass to connect to the broker).

Thanks in advance - hardly wait to get this working :slight_smile:

It goes into the configuration.yaml file

Step 4 - Configure Home Assistant to connect to mosquito - https://home-assistant.io/docs/mqtt/broker/#run-your-own
a) $ sudo nano /home/homeassistant/.homeassistant/configuration.yaml

b)Add this to the bottom of the file
    #Mosquitto MQTT
        broker:localhost
        username:mosquitto_username
        password:mosquitto_password

Thank you for your response but unfortunately this is not the reason why the connection gets refused, as I tried after removing the password from the MQTT Broker and I still get: "Socket error on client , disconnecting.
I had the user and password as you said and I thought that because of the user and password it gets refused.
Anyone can guide me into solving this ?

What command are you running when you get the error

The SmartThings Hub is sending commands.
The Mosquitto broker accepts messages as I am testing with a Tasmota Sonoff device which works perfectly:

1521470666: New client connected from 172.16.81.226 as DVES_A399D4 (c1, k15, u’edited user’).
1521470689: New connection from 172.16.81.215 on port 1883.
1521470689: Socket error on client , disconnecting.
1521470690: New connection from 172.16.81.215 on port 1883.
1521470690: Socket error on client , disconnecting.

the 215 is the SmartThings Hub

I think you have the port wrong on the ST Device.

Mosquitto listens on 1883, but the ST broker runs on 8080

This is the one I installed - thanks !

The previous post was shown logs from MQTT Broker side in which ST tried to communicate with Mosquitto.
In ST, My Devices, MQTT Device has the info in which it should reach the Mosquito (MQTT ip, MQTT port and mac address) which are correct since I see the ST trying to connect with Mosquitto, on the logs I showed in my previous post.

Anything else you can think of ? It must be something in the Mosquitto Broker since it doesn’t accept communication with ST, or the way the ST is sending those infos makes the Mosquitto refuse the connections.

Thanks a lot for trying to help !!!

Edited - where in Hass should I add info about the ST mqttbridge and port 8080 ?

The smartthings-mqtt-bridge listens on 8080 by default.
It should be at the bottom of the config.yml file created the first time you run smartthings-mqtt-bridge

In the MQTT Device settings in the ST app, the MQTT port needs to map whats in the config.yml file (8080 by default)

Since I am a noob, I got confused and thought that the MQTT Bridge is the MQTT broker.
So the problem is I did not install the MQTT bridge.
I guess I have to use SSH to install the bridge and the it will work - correct ?
If this is correct, in the ST, MQTT Device settings I should add the port, ip and mac address of the new created bridge - correct ?

The ST MQTT Bridge will communicate between ST and Mosquitto

You may or may not have completed some of this

Step 1 - Install smartthings-mqtt bridge - GitHub - stjohnjohnson/smartthings-mqtt-bridge: Bridge between SmartThings and MQTT
a) Install smartthings-mqtt-bridge
npm install -g smartthings-mqtt-bridge

b) run once to create the config.yml file
smartthings-mqtt-bridge
c)exit via ctrl-c

d) update config.yml - check host, username, and password
nano config.yml

    host: mqtt://localhost
    username: mosquitto_username
    password: mosquitto_password

Step 2 - Install SmartThings Device Handler and Smart App -

Device Handler - https://github.com/stjohnjohnson/smartthings-mqtt-bridge/blob/master/devicetypes/stj/mqtt-bridge.src/mqtt-bridge.groovy

Smart App -https://github.com/stjohnjohnson/smartthings-mqtt-bridge/blob/master/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy

a) Create new DH in IDE

b)Add new device from IDE

c) My Devices → MQTT Bridge → edit preferences

 MQTT Bridge IP Address: IP Address of RasPi
 MQTT Bridge Port: Default is 8080
 MQTT Bridge MAC Address: MAC Address of RasPi network adapter

d) IDE - Create new Smart App from Code

e) Add Smart App through Mobile App

Step 3 - Start Mosquitto and Verify No Errors
a) start smartthings-mqtt-bridge to run in background
smartthings-mqtt-bridge &

b) run mosquitto_sub to check status of devices
sudo mosquitto_sub -u mosquitto_user -P mosquitto_password -v -t '#'

Thanks a lot !
I will try and let you know how it went.

Noob here again, just as a reminder :slight_smile:
I can ssh into my pi - this is how I should install the step 1 ?

Can you explain to a noob the Step 1 ?
I am confident that I can do the rest of the steps without any help so this is the only thing that I have trouble understanding since I tried to ssh npm install -g smartthings-mqtt-bridge (as root) and I get npm command not found. In the pi 3 I have only HassIo installed.

Hope is not to much trouble - thanks a lot !!!

Since you’re running hass.io, it’s going to be a little different to set up the ST bridge (Step 1) vs my install which is running on hassbian

Here are those instructions to install via docker - https://github.com/stjohnjohnson/smartthings-mqtt-bridge#docker

You’ll need to update the config file if using a username & password (Step 1D) the only difference is the file will be found in /opt/mqtt-bridge/config.yml
so you’ll do

sudo nano /opt/mqtt-bridge/config.yml

If you get an error that nano isn’t found, use
sudo vi/opt/mqtt-bridge/config.yml

Step 2 will be as is.
Step 3, I believe you’ll just use the docker restart mqtt-bridge

Thanks a lot for your effort but I have no success with docker pull either:

core-ssh:~# docker pull stjohnjohnson/smartthings-mqtt-bridgedocker pull stjohnjohnson/smartthings-mqtt-bridge
-bash: docker: command not found

What I am missing now ?

I’m running out of ideas, but this may work

Try using those instructions with this github url

I got the bridge working with this last method - thank you !
Now, I can see messages coming from ST to this bridge but the switch for example does not update in HA and I don’t see anything in the bridge or broker when I press the button of the switch in HA

The bridge configuration:
{
“broker_host”: “172.16.81.213”,
“broker_port”: 1883,
“preface”: “smartthings”,
“state_suffix”: “state”,
“command_suffix”: “cmd”,
“login”: “RADU”,
“password”: “”,
“bridge_port”: 8080
}

This is a switch from my configuration.yaml file:

  • platform: mqtt
    name: “Corner Lamp”
    state_topic: “smartthings/Corner Lamp/switch”
    command_topic: “smartthings/Corner Lamp/switch”
    brightness_state_topic: “smartthings/Corner Lamp/level”
    brightness_command_topic: “smartthings/Corner Lamp/level”
    temperature_state_topic: “smartthings/Corner Lamp/colorTemperature”
    temperature_command_topic: “smartthings/Corner Lamp/colorTemperature”
    qos: 1
    payload_on: “on”
    payload_off: “off”
    retain: true

This is what I get in the bridge: info: Incoming message from SmartThings: smartthings/Corner Lamp/switch/state = on

And this is what I see in the Mosquitto broker:
1521496137: New client connected from 172.16.81.213 as mqttjs_d536c6a1 (c1, k10, u’RADU’).
1521496774: Saving in-memory database to /data/mosquitto.db.
1521496794: Client 2933187b-21c6-4d3b-b56b-ea120838ce90 disconnected.
1521496814: New connection from 172.16.81.213 on port 1883.
1521496814: New client connected from 172.16.81.213 as 9e5678aa-2c7e-463b-93f9-0f2fca6bb815 (c1, k60).
1521498575: Saving in-memory database to /data/mosquitto.db.
1521500376: Saving in-memory database to /data/mosquitto.db.
1521502177: Saving in-memory database to /data/mosquitto.db.

Mosquitto config:
{
“plain”: true,
“ssl”: false,
“anonymous”: true,
“logins”: ,
“customize”: {
“active”: false,
“folder”: “mosquitto”
},
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”
}

Since the ST bridge is running on the same IP as the HA (213) I set a login name into ST bridge (“RADU”) so I know which info’s are from him.

Can you think of something that I should change to make this work ?
Thanks a lot for your support !!!

I got it to work from ST to HA - I was missing the /state at the end of the topic
Now the problem remains that HA doesn’t send anything to ST (the switch state for example is not updated when I change the state from HA, but it updates in HA when I change the state from ST).
If you can see something wrong in my config
Thank you !