Smartthings MQTT Bridge

Did you get it working. I still cannot control lights from HA panel but it sends all the commands i can see it on MQTT logs ans ST logs. Works from ST hub properly.

For me its working but i cant figure out for my fibaro rgbw controlers because the colours dont work. Ordinary white dimmer lights work for me. Would be nice if you share some pics of the log in ST

I got mine working but ended up using my old wink hub as it just made things easier anyways.

Any luck with the Node versioning issue? Getting same issue here but it has only been 2 days working on it. :slight_smile: It would appear to be the only reason why I’m not able to start the smartthings-mqtt-bridge with PM2

[PM2][ERROR] Process smartthings-mqtt-bridge not found

@avnerg

After spending three days and some nights over it, I think it’s a good time to ask for some help.
I guess most of my issues are trivial but I am new to some of these technologies and issues are probably basic.
Anyway, I must have it working and not going to give up easy :slight_smile:

Installed the HASSbian RPI with its built-in MQTT. Works great. Have an Arduino communicates with it. Noted that out of the box it is already using three ports: 8123, 1883 and 8080.

Tried the NPM method described here.

  1. Installed NPM.
  2. Noted that I must install the package using sudo.
  3. Noted that I get warnings from the kind of: wanted: {“node”:“>= 0.12”} (current: {“node”:“0.10.29”,“npm”:“1.4.21”})

Just thought I’d chime in here since I was in this boat before I got things sorted/figured out and working correctly (mostly from the posts in this thread). With version 0.44 released today, HA has native Z-Wave and Zigbee support, so you maybe be able to remove MQTT and SmartThings from your setup now as an alternative/path forward.

-Chad

Aah, I’m running Mosquitto in a jail and could not figure out why it didnt work, until I read this and realised I have to use the host MAC and not the jail MAC :S

1 Like

Hey, I realise I’m a bit late to the party here, but I followed your instructions and mine is working perfectly. So… hopefully that makes you feel a little better :-).

One thing I did notice, in your ~/config.yml your port: 8080 is nested under mqtt:, I believe it should be at the root, at least mine is, so try moving it back a couple of spaces. Here’s mine:

---
mqtt:
    # Specify your MQTT Broker's hostname or IP address here
    host: localhost
    # Preface for the topics $PREFACE/$DEVICE_NAME/$PROPERTY
    preface: smartthings

    # Suffix for the state topics $PREFACE/$DEVICE_NAME/$PROPERTY/$STATE_SUFFIX
    # state_suffix: state
    # Suffix for the command topics $PREFACE/$DEVICE_NAME/$PROPERTY/$COMMAND_SUFFIX
    # command_suffix: cmd

    # Other optional settings from https://www.npmjs.com/package/mqtt#mqttclientstreambuilder-options
    username: redacted
    password: redacted

# Port number to listen on
port: 8080

Also, I didn’t have to copy the config.yml, it seemed to appear in the pi home dir on it’s own after starting the mqtt bridge via pm2. I then just edited it and restarted the bridge.

1 Like

Hi
I can connect alright. I see the logs and it says that i has subscribed to
info: Subscribing to smartthings/Drawing Room MS/temperature

I have the following setup as a sensor and use the sensor.yaml file

  • platform: mqtt
    name: ‘Drawing Room Temp’
    state_topic: “smartthings/Drawing Room MS/temperature”
    command_topic: “smartthings/Drawing Room MS/temperature”
    unit_of_measurement: ‘°C’
    device_class: temperature
    payload_on: “active”
    payload_off: “inactive”
    retain: true

The sensor shows up but no values. Any help would be appreciated. Thanks

I am getting the following error when I run the log but then it seems to be working fine.
[TAILING] Tailing last 15 lines for [smartthings-mqtt-bridge] process (change the value with --lines option)
/home/pi/.pm2/logs/smartthings-mqtt-bridge-error-0.log last 15 lines:
0|smartthi | at Writable.write (/usr/local/lib/node_modules/smartthings-mqtt-bridge/node_modules/mqtt/node_modules/readable-stream/lib/_stream_writable.js:194:11)
0|smartthi | at write (_stream_readable.js:585:24)
0|smartthi | at flow (_stream_readable.js:594:7)
0|smartthi | at Socket.pipeOnReadable (_stream_readable.js:626:5)
0|smartthi | Error: Connection refused: Not authorized
0|smartthi | at MqttClient._handleConnack (/usr/local/lib/node_modules/smartthings-mqtt-bridge/node_modules/mqtt/lib/client.js:735:9)
0|smartthi | at MqttClient._handlePacket (/usr/local/lib/node_modules/smartthings-mqtt-bridge/node_modules/mqtt/lib/client.js:296:12)
0|smartthi | at process (/usr/local/lib/node_modules/smartthings-mqtt-bridge/node_modules/mqtt/lib/client.js:238:12)
0|smartthi | at Writable.writable._write (/usr/local/lib/node_modules/smartthings-mqtt-bridge/node_modules/mqtt/lib/client.js:248:5)
0|smartthi | at doWrite (/usr/local/lib/node_modules/smartthings-mqtt-bridge/node_modules/mqtt/node_modules/readable-stream/lib/_stream_writable.js:237:10)
0|smartthi | at writeOrBuffer (/usr/local/lib/node_modules/smartthings-mqtt-bridge/node_modules/mqtt/node_modules/readable-stream/lib/_stream_writable.js:227:5)
0|smartthi | at Writable.write (/usr/local/lib/node_modules/smartthings-mqtt-bridge/node_modules/mqtt/node_modules/readable-stream/lib/_stream_writable.js:194:11)
0|smartthi | at write (_stream_readable.js:585:24)
0|smartthi | at flow (_stream_readable.js:594:7)
0|smartthi | at Socket.pipeOnReadable (_stream_readable.js:626:5)

But then after that I get the follwing
/home/pi/.pm2/logs/smartthings-mqtt-bridge-out-0.log last 15 lines:
0|smartthi | info: Skipping duplicate message from: smartthings/Drawing Room MS/temperature = 34.6
0|smartthi | info: Incoming message from MQTT: smartthings/Drawing Room MS/motion = inactive
0|smartthi | info: Skipping duplicate message from: smartthings/Drawing Room MS/motion = inactive
0|smartthi | info: Incoming message from MQTT: smartthings/Drawing Room MS/humidity = 43
0|smartthi | info: Skipping duplicate message from: smartthings/Drawing Room MS/humidity = 43
0|smartthi | info: Incoming message from MQTT: smartthings/Drawing Room MS/illuminance = 0
0|smartthi | info: Skipping duplicate message from: smartthings/Drawing Room MS/illuminance = 0
0|smartthi | info: Incoming message from MQTT: smartthings/Main Door Lock/lock = locked
0|smartthi | info: Skipping duplicate message from: smartthings/Main Door Lock/lock = locked
0|smartthi | info: Starting SmartThings MQTT Bridge - v1.3.4
0|smartthi | info: Loading configuration
0|smartthi | info: Loading previous state
0|smartthi | info: Perfoming configuration migration
0|smartthi | info: Saving current state
0|smartthi | info: Connecting to MQTT at mqtt://localhost

From the last part of the log, everything looks it should be ok. What about your homeassistant.log, is it connecting to mosquitto?

All is working fine. The first part always shows up so was wondering. During install I got the node is older and need newer but it never installs the newer one and everything works fine…except for the error. I reinstalled and the same messages show up.

Can someone point me in the right direction to auto run pm2 start smartthings-mqtt-bridge upon every reboot. im pretty novice at this stuff.

Thanks

After you run the ST bridge the first time with

pm2 start smartthings-mqtt-bridge

Run these commands:

pm2 save
pm2 startup -u pi

The PM2 startup command will give you an error, but will give you the correct command to run to make it work properly. It will tell you to run something like this:

sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u pi --hp /home/pi

That’s it. There is another way I know how to do it, but it only works with a Raspian Jessie w/ Pixel setup.

I’m having a real hard time linking homeassistant to my smartthings app.

When I run pm2 log smartthings-mqtt-bridge it outputs

[STREAMING] Now streaming realtime logs for [smartthings-mqtt-bridge] process
0|smartthi | info: Starting SmartThings MQTT Bridge - v1.3.4
0|smartthi | info: Loading configuration
0|smartthi | info: Loading previous state
0|smartthi | info: Perfoming configuration migration
0|smartthi | TypeError: Parameter 'url' must be a string, not undefined
0|smartthi |     at Url.parse (url.js:107:11)
0|smartthi |     at Object.urlParse [as parse] (url.js:101:5)
0|smartthi |     at migrateState (/usr/local/lib/node_modules/smartthings-mqtt-bridge/server.js:127:14)
0|smartthi |     at loadFromDisk (/usr/local/lib/node_modules/smartthings-mqtt-bridge/server.js:302:9)
0|smartthi |     at /usr/local/lib/node_modules/smartthings-mqtt-bridge/node_modules/async/lib/async.js:718:13
0|smartthi |     at iterate (/usr/local/lib/node_modules/smartthings-mqtt-bridge/node_modules/async/lib/async.js:262:13)
0|smartthi |     at async.forEachOfSeries.async.eachOfSeries (/usr/local/lib/node_modules/smartthings-mqtt-bridge/node_modules/async/lib/async.js:281:9)
0|smartthi |     at _parallel (/usr/local/lib/node_modules/smartthings-mqtt-bridge/node_modules/async/lib/async.js:717:9)
0|smartthi |     at Object.async.series (/usr/local/lib/node_modules/smartthings-mqtt-bridge/node_modules/async/lib/async.js:739:9)
0|smartthi |     at Object.<anonymous> (/usr/local/lib/node_modules/smartthings-mqtt-bridge/server.js:287:7)

How can I resolve this??

If I run mosquitto_sub -u pi -P raspberry -v -t '#' and toggle the switches on the UI it logs smartthings/Bed Fan Light/switch off so it seems to be working properly just not sending it to the smartthings servers.

I’m not sure what url it’s talking about and why it’s undefined… Any ideas?

In the bridge device you have to configure with a URL, did you do that?

In the SmartThings app?? Mine doesn’t have those fields? But the IDE online does

You should have created a smart app as well as a bridge device, those settings are under the device

Oh sorry, didn’t realize that I could see all that from the app. But yes mine looks similar

Ok so I fixed that error… I must have accidentally changed the file name so it couldn’t find it.

No running pm2 restart smartthings-mqtt-bridge && pm2 log smartthings-mqtt-bridge
logs out

[STREAMING] Now streaming realtime logs for [smartthings-mqtt-bridge] process
0|smartthi | info: Starting SmartThings MQTT Bridge - v1.3.4
0|smartthi | info: Loading configuration
0|smartthi | info: Loading previous state
0|smartthi | info: Perfoming configuration migration
0|smartthi | info: Saving current state
0|smartthi | info: Connecting to MQTT at mqtt://localhost

The command sudo systemctl status mosquitto.service -l shows mqtt as running.

The command mosquitto_sub -u pi -P raspberry -v -t '#' still logs the activity if I toggle the switches on the UI or use a command like mosquitto_pub -h 192.168.0.200 -u username -P password -t "smartthings/Bed Fan Light/switch" -m "on"

(192.168.0.200 is the ip of my pi, but it also logs with 127.0.0.1 and localhost)

Manually entering those commands, I can’t see anything in the pm2 log smartthings-mqtt-bridge output nor in the smartthings IDE logs.

Any help would be greatly appreciated!

So it should go:

Device Handler --> Device --> MQTT-Bridge --> MQTT --> HA

You double checked the Device has the correct IP, Port, and MAC for the MQTT Bridge.

Have you verified your MQTT-bridge settings point to the MQTT Broker properly? Should be the config.yml file and look something like this:

---
mqtt:
    # Specify your MQTT Broker's hostname or IP address here
    host: 192.168.1.188 
    # Preface for the topics $PREFACE/$DEVICE_NAME/$PROPERTY
    preface: smartthings

    # Suffix for the state topics $PREFACE/$DEVICE_NAME/$PROPERTY/$STATE_SUFFIX
    # state_suffix: state
    # Suffix for the command topics $PREFACE/$DEVICE_NAME/$PROPERTY/$COMMAND_SUFFIX
    # command_suffix: cmd

    # Other optional settings from https://www.npmjs.com/package/mqtt#mqttclientstreambuilder-options
    username: yourusername
    password: yourpassword

# Port number to listen on
port: 8080