Smartthings MQTT Bridge

@bdgf10 I’m having the same issue where I have a ihome switch and it randomly turn off or on. Example, the switch is off and I use Smartthings or iHome native app to turn on the switch, it will turn on. But, after a few minutes it will automaticaly turn off. However, if I turn it on with HomeAssistant, it stays on forever.

To troubleshoot, I shutdown HomeAssistant and try to use the native apps (iHome and/or Smartthings). When I turn it on, it stays on permanently. So, I’m thinking HomeAssistant is the source of where the issue is.

Any ideas how to troubleshoot?

Is there any additional logging I can turn on to troubleshoot? I tried the following:

logger:
  default: critical
  logs:
    homeassistant.components.switch: debug

@kdubmisc I’m facing your exact issue. If I disable the SmartThings-mqtt-bridge then everything works fine, but I’m also thinking it has something to do with state management in HA. I haven’t had time to troubleshoot it much, but will try to look into it soon.

Another question: Did you install the smartthings bridge manually or via an addon?

Post back if you make any progress. I have a feeling it is something simple…

Thinking about it some more, it looks like you and I both appending /state and /cmd to the end of our topics. That might have something to do with it.

@bdgf10 I’m using the docker install version of HA. I’ve used smartthings bridge as addon

I did do some additional troubleshoot. I stop all the services: Mosquitto MQTT and Smartthings Bridge.
I then went to manually delete the mosquitto.db file. After I deleted the mosquitto.db file, i restated HA, started Mosquitto MQTT and Smarthings Bridge.

It seems to be working for the last 4 days so far. Hopefully it remains stable.

Looking for Help :thinking:

I finally got my HA to read the state of the device but I can’t control it through HA. Here is my setup:


Raspberry Pi 3 with Hassio installed


Mosquitto Broker (Hassio plugin)

{
  "plain": true,
  "ssl": false,
  "anonymous": false,
  "logins": [
    {
      "username": "uname",
      "password": "pword"
    }
  ],
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem"
}

SmartThingsBridge (plugin from here)

{
  "broker_host": "192.168.1.31",
  "broker_port": 1883,
  "preface": "smartthings",
  "state_suffix": "state",
  "command_suffix": "cmd",
  "login": "uname",
  "password": "pword",
  "bridge_port": 8080
}

configuration.yaml (HA config file)

mqtt:
  broker: 192.168.1.31
  protocol: 3.1
  keepalive: 60
  client_id: hass-1
  username: uname
  password: pword

light:
  - platform: mqtt
    name: "Living Room Lamp"
    state_topic: "smartthings/Living Room Lamp/switch/state"
    command_topic: "smartthings/Living Room Lamp/switch/cmd"
    payload_on: "on"
    payload_off: "off"
    retain: true

MQTT-Bridge Device

MQTT Bridge IP Address: 192.168.1.31
MQTT Bridge Port: 8080
MQTT Bridge MAC Address: [my pi mac address]


“Living Room Lamp” is a smart bulb (not a switch). If I turn it on via actiontiles, the switch in HA turns on but I cannot control it from HA.

Does anyone see anything I’m missing?

I have the same vkorn add-on you do. I have an extremely similar issue to you.

Communication has been very one way, state updates from smartthings have been good, HA, reflects them almost instantly. Try to turn the light off in HA and MQTT fires the off cmd to the bridge, but nothing happens except HA flipping the status back to “off” a few seconds later.

info: Subscribing to smartthings/Dining Hall/switch/cmd
info: Incoming message from SmartThings: smartthings/Dining Hall/switch/state = on
info: Incoming message from SmartThings: smartthings/Dining Hall/switch/state = off
info: Incoming message from SmartThings: smartthings/Dining Hall/switch/state = on
info: Incoming message from MQTT: smartthings/Dining Hall/switch/cmd = off
info: Incoming message from MQTT: smartthings/Dining Hall/switch/cmd = off

EDIT:
It’s important to use the correct MAC

MAC address is everything in smartthings, My pi was connected via wi-fi, smartthings wanted to see the wlan0 MAC address of my PI, not the eth0 address. Good Luck!

I have the same issue. Smartthings reports the states, but i cannot change a state from HA to Smartthings.

On top, Smartthings doesnt even show anything in the log if i try to push a command to it.

Did you see my note about the MAC address? Make sure the MAC address in your smartthings MQTT bridge is correct. That was my problem, I had the eth0 MAC address for my raspberry PI when I needed the wlan0 MAC address because my PI was connected wirelessly.

If you don’t have the MAC address in your smartthings MQTT bridge device, nothing will appear in smartthings even though the bridge is receiving/sending messages.

1 Like

I actually just changed it to the wlan0 MAC and it works. Which is weird to me, because my PI is connected via Ethernet & WIFI. Maybe i need to disable the WiFi Part to make it work via Ethernet.

@bdgf10 Did you ever figure out your issue? I have the same problem and have not been able to figure it out. If I turn off a light with HA, then use the physical switch to turn it on, it will turn off on its own after a few minutes.

You’re my hero. This was the missing piece of the puzzle. THANK YOU!

Hello I am in the same situation as you. Did you find the problem that caused HA to send the reverse command some minutes later. ?

Yes, I removed the “Retain: true” flags from my config for each switch and then reinstalled the MQTT broker. Haven’t had any issues since.

I also removed the ¨retain:true¨ but have also an issue with the smartthings outlet and fibaro rgbw controller. I turn it on via smartthings or HA but it turns off in 10-13 min. I also didn’t find the solution for the rgbw color for the controller.:confused:

Did you uninstall and re-install your MQTT broker? If you just removed the flag but did not do anything with the broker it will still be there.

thank you
it works perfectly on my side since I removed the retain: true flag. I did exactly what you described to me and everything rolls as it should. thank’s again

Thank you.
I removed the MQTT broker again and it seems to work just great slight_smile:. I never thought the broker would be an issue when I just edited .yaml config

edit:
Could you also help to figure out a config for the fibaro rgbw controllers, I tried many different approaches but couldn’t get the colors work.
Matt publishes: color = [red:108, green:255, blue:255, white:255, hue:50.0, saturation:57.647061347961426, level:100, hex:#6cffff, name:custom]
Tried it with some templating but doesn’t work. when I don’t specify anything just the color path I can adjust the color but it changes wrong. I select blue and turns out red and so on.

Glad to hear that worked! Unfortunately, I don’t have any experience with RGBW controllers so I don’t think I can offer any assistance there. Hopefully someone else can help. Good luck!

1 Like

For what it’s worth, I can confirm that this works on a SmartThings Link hub with the Nvidia Shield. I just upgraded to the ST Link so I could give my ST hub 2 to my father-in-law. As much I was dreading having to re-create all my SmartThings automations, smartapps, etc. since they don’t have an easy way to migrate, I was more worried about getting the MQTT-Bridge set back up. To say it was a cakewalk would be an overstatement. But all the issues were little silly mistakes on my part. Once I got all my misspelled device names corrected, it worked just as solidly as it had before.

I read this post and I think it could help me because – even when I run smartthings-mqtt-bridge with pm2, I can find nothing listening on port 8080; your post makes me wonder if I am editing the wrong config.yml on MY system. When you wrote this:

However, when smartthigns-mqtt-bridge is looking for its configuration in the process directory, NOT the node_modules directory.

server.js

var CONFIG_DIR = process.env.CONFIG_DIR || process.cwd(),
** CONFIG_FILE = path.join(CONFIG_DIR, ‘config.yml’),**

I realized I didn’t know what the paths that setting maps to, locally.