Smarter SmartThings with MQTT and Home Assistant

Hi there,
thanks a lot for this. I was wondering if there is anyway to bypass the ST hub. I want to use RPi and zigbee usb stick and smartthings multisensor.
appreciate if any help could be provided.
Thanks
Ali

@Ali_Kiaie yes you want to use the zha or deconz components.

I am totally new. Trying to decide what is best. I live in Australia so limited on Zwave. My research says smartthings window sensors are very good

How can I monitor a ST Sensor in HA, I tried binary_sensor but does not pick up motion.

Thank you for this. I am working through the instructions and have got to adding a new device on the Smartthings IDE. I have completed the fields as instructed but when I click the CREATE button I get the following error - ‘A Device must have either a Location or a Hub.’ The form is then reset. I have filled in the fields once again but find that there is no way to either enter or select a value for the Location or Hub fields.

Can anyone help?

Thank you

Sorry, my mistake, I had not selected the location and hub in the IDE. Must be the effect of a busy week. It is now working as expected. DOH!

Hello,

Thanks for creating this, I was teetering back and forth of switching over and this made the decision easy. One issue I have, and I think its related to my having the nvidia shield smartthings stick is that the incoming messages are not working. The info panel shows ip/mac/port as all 0 in smartthings so I hardcoded it in the code to no avail.

Data streams from smartthings to the bridge, that all looks good. But when I click a button in home assistant I get:

mqttbridge_1     | info: Incoming message from MQTT: smartthings/Dehumidifier/switch = on
mqttbridge_1     | error: Error from SmartThings Hub: Error: connect ECONNREFUSED 192.168.1.241:39500
mqttbridge_1     | error: {
mqttbridge_1     |     "errno": "ECONNREFUSED",
mqttbridge_1     |     "code": "ECONNREFUSED",
mqttbridge_1     |     "syscall": "connect",
mqttbridge_1     |     "address": "192.168.1.241",
mqttbridge_1     |     "port": 39500
mqttbridge_1     | }
mqttbridge_1     | error:

Anyone know where I should go from here?

Thanks,

looks like the shield is the problem; replacing it with a non-shield.

I’m having one HELL of a time getting this to work. Bought a smarthings hub yesterday, spent all night last night (literally about 7 hours), and the better part of today trying to get this to work. No dice.

I’m running kubernetes, so it’s a little different than docker, but shouldn’t be hard. From what i can see, HA hits the mqtt and bridge, but never makes it to Smartthings, and vice versa (using smart things app doesn’t update HA)

Bridge logs:

Info: Incoming message from SmartThings: smartthings/Front Door Lock/lock = unlocked
info: Incoming message from MQTT: smartthings/Front Door Lock/lock = unlocked
info: Skipping duplicate message from: smartthings/Front Door Lock/lock = unlocked
info: Incoming message from SmartThings: smartthings/Front Door Lock/lock = locked
info: Incoming message from MQTT: smartthings/Front Door Lock/lock = locked
info: Skipping duplicate message from: smartthings/Front Door Lock/lock = locked
info: Incoming message from MQTT: smartthings/Front Door Lock/lock = unlocked
info: Incoming message from MQTT: smartthings/Front Door Lock/lock = locked
error: Error from SmartThings Hub: Error: connect EHOSTUNREACH 192.168.1.88:39500
error: {
    "errno": "EHOSTUNREACH",
    "code": "EHOSTUNREACH",
    "syscall": "connect",
    "address": "192.168.1.88",
    "port": 39500
}
error:
error: Error from SmartThings Hub: Error: connect EHOSTUNREACH 192.168.1.88:39500
error: {
    "errno": "EHOSTUNREACH",
    "code": "EHOSTUNREACH",
    "syscall": "connect",
    "address": "192.168.1.88",
    "port": 39500
}

the changes are me hitting the button lock/unlock in HA

mqtt-bridge config:

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

# The write and read suffixes need to be different to be able to differentiate when state comes from SmartThings or when its coming from the physical device/application

# Suffix for the topics that receive state from SmartThings $PREFACE/$DEVICE_NAME/$PROPERTY/$STATE_READ_SUFFIX
# Your physical device or application should subscribe to this topic to get updated status from SmartThings
# state_read_suffix: state

# Suffix for the topics to send state back to SmartThings $PREFACE/$DEVICE_NAME/$PROPERTY/$STATE_WRITE_SUFFIX
# your physical device or application should write to this topic to update the state of SmartThings devices that support setStatus
# state_write_suffix: set_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: AzureDiamond
# password: hunter2

# Port number to listen on
port: 8080

192.168.1.20 is the ip of the first K8s host, running mosquitto (i tried both in a k8s container but had the same results, so i tried bare metal…no change

my HA “lock.yaml” file

- platform: mqtt
name: "Front Door Lock"
state_topic: "smartthings/Front Door Lock/lock"
command_topic: "smartthings/Front Door Lock/lock"
payload_lock: "locked"
payload_unlock: "unlocked"
retain: true

my HA config

mqtt:
broker: 192.168.1.20
#port: 1883
protocol: 3.1
client_id: home-asssistant-1
keepalive: 60
username: hass
password: password

It seems like both ends work, they just can’t talk in the middle.

I had this problem after I changed my STHub IP. Check state.json in the mqtt-bridge config directory. I just changed the ip to the new one and restarted mqtt-bridge.

It is trying to callback to the hub and can’t.

Are you using the SmartThings “Classic” app with a SmartThings account or are you migrated to a Samsung account and using the “Connect” app. The new Samsung accounts and Connect app crippled SmartThings and does NOT support custom device handlers. Such as the MQTT bridge device handler. You may want to check on the SmartThings community site there’s a lot of noise about the DTH issue and the Samsung conversion.

I’m using the classic app on my phone, but not sure how the phone app affects MQTT bridge and/or smartthings hub?

The app itself doesn’t affect things, however if your account was migrated to the “new” Samsung account then you can’t (currently) use third party SmartApps like the MQTT app. Lots of things over there are breaking with the Samsung account changes.

is there a way to go back to the smartthings account insted of the samsung account?

This writeup seems to focus largely on publishing a SmartThings device to Home Assistant. I’m trying to publish a set of RPi GPIO binary sensors from Home Assistant to SmartThings. Everything is working up to the point where there doesn’t seem to be any device handlers to publish from Home Assistant. Am I correct in thinking this is not possible with the pieces assembled here to date? If it is, I don’t see it.

There appears to be a bug.

The MQTT-Bridge clearly state:
“Suffix for the topics to send state back to SmartThings $PREFACE/$DEVICE_NAME/$PROPERTY/$STATE_WRITE_SUFFIX”
“Suffix for the command topics $PREFACE/$DEVICE_NAME/$PROPERTY/$COMMAND_SUFFIX”

However, if $DEVICE_NAME is something like “thirdbedroom/outlet” nothings gets set in SmartThings as the Device Handler’s events list in the ST IDE says:

MQTT Device message is {“name”:“thirdbedroom”,“command”:true,“value”:“off”,“type”:“outlet”}

Instead of:
MQTT Device message is {“name”:“thirdbedroom/outlet”,“command”:true,“value”:“off”,“type”:“switch”}

If I changed the device name to thirdbedroom.outlet things work fine so it is likely some regex issue. I am not using Home Assistant, so I don’t know if forward slashes are allowed in the names or not.

If the bridge could be made to list the location before the device name as an option, that would be great for my use case. However, I just wanted to post this just in case someone else spends a few hours only to discover this small bug.

Irregardless, this is a very neat project, so please keep up the great work :slight_smile:

I wonder, am I able to connect the HA with Alexa or Google Assistant that run on ST?

I’ve got the bridge installed, all the code in to SmartThings IDE, in the ST app, I’ve selected the bridge, I’ve enabled a couple of switches and motion sensors but HomeAssistant is still saying: “This integration has no devices.”

I can see and control devices that I manually add in configuration.yaml

Any pointers on how to diagnose the failing discovery process?

Did you go into the smartthings app, click on a device, click on SmartApps, then add the device to the Mqtt App?

yes, all those that i want are ticked.