stjohnjohnson / smartthings-mqtt-bridge

Bridge between SmartThings and MQTT
https://hub.docker.com/r/stjohnjohnson/smartthings-mqtt-bridge/
MIT License
363 stars 241 forks source link

doesn't pull messages from MQTT #48

Open TheCase opened 8 years ago

TheCase commented 8 years ago

I've finally managed to get HomeAssistant to reflect the current state of a Smartthings device. I can change the device state via Smartthings app and it updates in HA webui. The webui will also update when I send a pub directly to MQTT

What doesn't work is the bridge recognizing state changes in MQTT and sending the commands to SmartThings. I never see the "Incoming message from MQTT: " message in the output of mqtt-bridge. I've tried the mosca Docker container as well as mosquitto for the MQTT broker: same results. I also tried the Docker container for mqtt-bridge as well as the npm app. Again, same results. The bridge never picks up event requests from HA to send to ST.

I'm sure there is something small that I'm missing. Here is my config:

mqtt:
  host: mqtt://192.168.1.23:1883
  preface: smartthings

port: 8080
sneakyflint commented 7 years ago

I'm also experiencing the same issue with the same config.

stjohnjohnson commented 7 years ago

The main reason this would happen is if the mac address wasn't configured right on the SmartThings side. So the mac address has to be from the outer machine (not inside the container). SmartThings straight up ignores all connections from anything that is not that mac address.

TheCase commented 7 years ago

mac address verified to be that of the container host. Anything else I can check?

This really seems like an issue with the bridge failing to recognize topic state changes in MQTT.

If it were a issue with the mac, I'd still expect the bridge to pick up the state change and maybe fail later down the line.

sneakyflint commented 7 years ago

Mac address was wrong, but I updated it and the device ID accordingly and the bridge still isn't working.

stjohnjohnson commented 7 years ago

Can you give me a gist with the events.log from the bridge and the logging from SmartThings UI?

Seth-Miller commented 7 years ago

I was having the same issue. Changing the MAC address worked for me. Make sure you are using the MAC address of the NIC on your network, not the docker virtual NIC.

@stjohnjohnson Might I suggest adding this to the documentation. It would have saved me many hours of troubleshooting and frustration.

TheCase commented 7 years ago

Found the problem. Moral of the story: don't use the '#' or '+' characters in your device names. MQTT sees them as wildcards. I had a device temporarily named Door Sensor #10 and it obviously threw off the subscription list in the Bridge.

stjohnjohnson commented 7 years ago

@TheCase Reeallly interesting. I can either change the documentation or automatically change # or + into some other characters. Do you have an opinion?

@Seth-Miller Good idea. Will do.

TheCase commented 7 years ago

@stjohnjohnson I'd say documenting it should be good enough for now. It was enough of an outside case that I think I was the first to get bitten by it.

I'll leave this issue open for you to close once you update the docs.