Smarter SmartThings with MQTT and Home Assistant


#41

Your configuration.yaml looks correct.
Here is mine for comparison:

switch:  
  - platform: mqtt
    name: "Spare Plug"
    icon: mdi:power-socket-us
    state_topic: "smartthings/Spare plug/switch"
    command_topic: "smartthings/Spare plug/switch"
    payload_on: "on"
    payload_off: "off"
    retain: true

#42

@wmaker
Thanks for checking it. So I am wandering if the Home Assistant <–> MQTT isnt working.
I am assuming the messages I see from mosquitto_sub -v -t ‘smartthings/#’ prove that STT Hub is communicating to MQTT running on my Pi?
But when I mosquitto_sub -v -t ‘homeassistant/#’_ and action the switch via HA Overview I dont see any messages in mosquitto.

Has anyone any suggestions how I can test -

  1. MQTT <–> Home Assistant connection
  2. MQTT–>STT Hub

#43

May try

mosquitto_sub -v -t ‘#’

which will allow you to see all topics being published (in case HA published something unexpected)

In your configuration.yaml file, double check your for mqtt settings, and include a client_id:

 mqtt:
   broker: localhost
   protocol: 3.1
   client_id: some_name

Look at the latest timeline of your mosquitto log and see if there is something like:

545958535: New client connected from 127.0.0.1 as some_name

If you see this, then HA has successfully connected to the mosquitto broker.


#44

Does anyone have a feel for how well this works? Particularly with less common Z-Wave items, like locks and thermostats? Like many others, I have Z-Wave woes with HA, and am entertaining ideas to improve the situation. Excluding and re-including all my devices into ST is no small task, so I wanted to poll others’ experiences to see if I can determine how likely I am to have success before actually pulling the trigger.


#45

Hi everyone
I am getting things working now between My SST Hub and HA

I have tried to configure a motion sensor but it doesnt seem to update when the motion sensor is activated.
Here is a snippet from the mosquitto_log
smartthings/HallwayMotion1/motion active
smartthings/HallwayMotion1/motion inactive

This is what I have in my configuration.yaml -
group: !include groups.yaml
automation: !include automations.yaml
zone: !include zone.yaml
sensor: !include sensor.yaml
switch: !include switch.yaml
device_tracker: !include device_tracker.yaml
script: !include scripts.yaml

binary_sensor:

  • platform: mqtt
    name: “Hallway”
    state_topic: “smartthings/HallwayMotion1/motion”
    payload_on: “active”
    payload_off: “inactive”
    qos: 0
    device_class: motion

Can someone point out what I am doing wrong please?


#46

Does anyone have a feel for how well this works?

The biggest complaint I have seen is that ST uses the cloud (except for the most common Zwave devices) including the ST-MQTT-Bridge. This can result in 1) delays and 2) non-functionality. For example I have a sensor that turns on a light and this can take from 1 second to as many as 10 seconds. If your internet connection goes down, or the ST cloud servers have gone down you can loose functionality, but I have never experienced this (yet).

As for device support, ST writes “device handlers” that the hub uses to support many common ZWave devices, and there are lots of “device handlers” developed by the community. There is a large community for ST, so chances are you’ll find a device handler for your device. Nevertheless, I always look to see if a device handler has been written for a Zwave device that I’m interested in.

Another problem to be aware of is when a single ZWave device has multiple instances of a function, say multiple buttons, you may find a device handler that supports the multiple buttons but it either can not communicate more than one button to the ST-MQTT-Bridge, or the ST-MQTT-Bridge can’t handle more than one (at least as far as I’ve been able to figure out).


#47

Good evening,

For the last week I have been trying to get ST or MQTT to receive the changes from HA and found this thread with great hopes that the add-on provided by @thewilliambond will get me there, but sadly I am still stuck on one-way communication (ST->HA).
Also, when I change the switch toggle in HA it does not “turn the light on” and instead changes back to off state about a second later. On the other hand, HA does update when I turn the light on from ST or via the physical switch.
My setup uses a Rasp_pi using Hassio as the OS.
I did try to use my Rasp_pi physical eth0 MAC address in the MQTT device created via ST IDE, but every time I do so, the MQTT bridge looses connection and no longer listens for changes, no matter how many times I go the the SmartApp, edit and save.
The only way I can make it work (half-way) is by using the eth0 MAC address i get from hassio when running the “ifconfig eth0” command via SSH. As soon as I do that, the bridge starts listing fine and one way communication gets back to work. Sadly though, editing and saving the SmartApp does not trigger the devices responding to HA commands.
I do see that all the ST devices been registered every time I update the smartApp.
Any help will be greatly appreciated. This is driving me nuts!


#48

Is there a way to troubleshoot the bridge?

I’ve carefully checked that all elements of smartthings app are entered correctly, added it on my phone, and selected devices and Bridge to notify.

I set up bridge on same server with docker. events.log shows start messages and no errors. I’m monitoring all activity on mqtt server and getting no data from any of the selected devices.

My understanding is that config port = smartthings device port. I’ve tried a variety of settings, both including mqtt port and leaving it out, as done in template.

---
mqtt:
# Specify your MQTT Broker's hostname or IP address here
host: mqtt://localhost
#host: mqtt://localhost:1883
# host: mqtt://192.168.86.63:1883
# 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/appli$

# 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: 8001

Device:
|Name|Type|Value|

|ip|string|192.168.86.63|
|mac|string|00:01:xx:xx:xx:xx|
|port|string|8001|

#49

Log:

> 2019-01-26T18:11:51.903Z - info: Starting SmartThings MQTT Bridge - v3.0.0
> 2019-01-26T18:11:51.905Z - info: Loading configuration
> 2019-01-26T18:11:51.906Z - info: No previous configuration found, creating one
> 2019-01-26T18:11:51.919Z - info: Loading previous state
> 2019-01-26T18:11:51.921Z - info: No previous state found, continuing
> 2019-01-26T18:11:51.921Z - info: Perfoming configuration migration
> 2019-01-26T18:11:51.927Z - info: Saving current state
> 2019-01-26T18:11:51.931Z - info: Connecting to MQTT at mqtt://mqtt
> 2019-01-26T23:03:22.410Z - info: Starting SmartThings MQTT Bridge - v3.0.0
> 2019-01-26T23:03:22.413Z - info: Loading configuration
> 2019-01-26T23:03:22.425Z - info: Loading previous state
> 2019-01-26T23:03:22.427Z - info: Perfoming configuration migration
> 2019-01-26T23:03:22.436Z - info: Saving current state
> 2019-01-26T23:03:22.441Z - info: Connecting to MQTT at mqtt://192.168.86.63
> 2019-01-26T23:03:22.480Z - info: Configuring autosave
> 2019-01-26T23:03:22.481Z - info: Configuring API
> 2019-01-26T23:03:22.516Z - info: Listening at http://localhost:8001
> 2019-01-26T23:11:43.371Z - info: Starting SmartThings MQTT Bridge - v3.0.0
> 2019-01-26T23:11:43.377Z - info: Loading configuration
> 2019-01-26T23:11:43.394Z - info: Loading previous state
> 2019-01-26T23:11:43.395Z - info: Perfoming configuration migration
> 2019-01-26T23:11:43.402Z - info: Saving current state
> 2019-01-26T23:11:43.406Z - info: Connecting to MQTT at mqtt://192.168.86.63
> 2019-01-26T23:11:43.448Z - info: Configuring autosave
> 2019-01-26T23:11:43.450Z - info: Configuring API
> 2019-01-26T23:11:43.484Z - info: Listening at http://localhost:8001
> 2019-01-26T23:14:19.465Z - info: Starting SmartThings MQTT Bridge - v3.0.0
> 2019-01-26T23:14:19.468Z - info: Loading configuration
> 2019-01-26T23:14:19.481Z - info: Loading previous state
> 2019-01-26T23:14:19.482Z - info: Perfoming configuration migration
> 2019-01-26T23:14:19.488Z - info: Saving current state
> 2019-01-26T23:14:19.493Z - info: Connecting to MQTT at mqtt://192.168.86.63:1883
> 2019-01-26T23:14:19.539Z - info: Configuring autosave
> 2019-01-26T23:14:19.541Z - info: Configuring API
> 2019-01-26T23:14:19.575Z - info: Listening at http://localhost:8001
> 2019-01-26T23:15:39.477Z - info: Starting SmartThings MQTT Bridge - v3.0.0
> 2019-01-26T23:15:39.480Z - info: Loading configuration
> 2019-01-26T23:15:39.500Z - info: Loading previous state
> 2019-01-26T23:15:39.501Z - info: Perfoming configuration migration
> 2019-01-26T23:15:39.508Z - info: Saving current state
> 2019-01-26T23:15:39.512Z - info: Connecting to MQTT at mqtt://192.168.86.63:1883
> 2019-01-26T23:15:39.555Z - info: Configuring autosave
> 2019-01-26T23:15:39.557Z - info: Configuring API
> 2019-01-26T23:15:39.591Z - info: Listening at http://localhost:8001
> 2019-01-26T23:28:38.477Z - info: Starting SmartThings MQTT Bridge - v3.0.0
> 2019-01-26T23:28:38.479Z - info: Loading configuration
> 2019-01-26T23:28:38.492Z - info: Loading previous state
> 2019-01-26T23:28:38.493Z - info: Perfoming configuration migration
> 2019-01-26T23:28:38.500Z - info: Saving current state
> 2019-01-26T23:28:38.506Z - info: Connecting to MQTT at mqtt://192.168.86.63:1883
> 2019-01-26T23:28:38.560Z - info: Configuring autosave

#50

I finally got MQTT Bridge working. It seems the issue was that the Docker container does not accept an alternate port. I tried using first settings,but once I used second container and config options below, I started getting MQTT data from Smartthings.

-p 8001:8001
and
port=8001

-p 8001:8080
and
port=8080

I uncommented the default configurations in the config file and tried sending return messages, however Smartthings does not respond.

2019-01-28T01:57:35.799Z - info: Incoming message from SmartThings: smartthings/Dining Room Light/switch/state = on
2019-01-28T01:57:35.896Z - info: Incoming message from SmartThings: smartthings/Dining Room Light/level/state = 34
2019-01-28T01:58:21.210Z - info: Incoming message from MQTT: smartthings/Dining Room Light/switch/set_state = off
2019-01-28T01:59:03.964Z - info: Incoming message from MQTT: smartthings/Dining Room Light/switch/cmd = off

Smartthings Live Log:

[ba8bf222-ca3a-457c-8534-00df90d27f9f](https://graph-na04-useast2.api.smartthings.com/ide/logs#ba8bf222-ca3a-457c-8534-00df90d27f9f) 9:22:12 PM: error received a request with an unknown path: POST / HTTP/1.1 
host: 192.168.86.43:39500 
accept: application/json 
content-type: application/json 
content-length: 74 
Connection: close

[ba8bf222-ca3a-457c-8534-00df90d27f9f](https://graph-na04-useast2.api.smartthings.com/ide/logs#ba8bf222-ca3a-457c-8534-00df90d27f9f) 9:22:12 PM: debug Msg '[index:10, mac:00012E6C42E0, headers:[content-length:74, connection:close, host:192.168.86.43:39500, content-type:application/json, accept:application/json, post / http/1.1:null], body:{"name":"Dining Room Light","type":"switch","value":"off","command":false}, header:POST / HTTP/1.1 
host: 192.168.86.43:39500 
accept: application/json 
content-type: application/json 
content-length: 74 
Connection: close, data:[command:false, name:Dining Room Light, type:switch, value:off], json:[command:false, name:Dining Room Light, type:switch, value:off]]'

[ba8bf222-ca3a-457c-8534-00df90d27f9f](https://graph-na04-useast2.api.smartthings.com/ide/logs#ba8bf222-ca3a-457c-8534-00df90d27f9f) 9:20:52 PM: error received a request with an unknown path: POST / HTTP/1.1 
host: 192.168.86.43:39500 
accept: application/json 
content-type: application/json 
content-length: 73 
Connection: close

[ba8bf222-ca3a-457c-8534-00df90d27f9f](https://graph-na04-useast2.api.smartthings.com/ide/logs#ba8bf222-ca3a-457c-8534-00df90d27f9f) 9:20:52 PM: debug Msg '[index:0E, mac:00012E6C42E0, headers:[content-length:73, connection:close, host:192.168.86.43:39500, content-type:application/json, accept:application/json, post / http/1.1:null], body:{"name":"Dining Room Light","type":"switch","value":"off","command":true}, header:POST / HTTP/1.1 
host: 192.168.86.43:39500 
accept: application/json 
content-type: application/json 
content-length: 73 
Connection: close, data:[command:true, name:Dining Room Light, type:switch, value:off], json:[command:true, name:Dining Room Light, type:switch, value:off]]'

#51

If any of the thread participants here have the actual mqtt platform definition for the ST motion sensors could you post it here ?

Thanks,

Heywood


#52

Did you get this sorted ?


#53

I don’t seem to be getting MQTT messages into my mosquitto MQTT broker.
I have everything in Docker containers.
In the Smartthings setup, you need to give the broker machine IP and MAC.
My question is; it the MAC address of the docker host or container ?


#54

SmartThings is getting a native integration in 0.87. I’d hold off and try using that instead.


#55

Thanks

Not sure what native integration is

I have

|Firmware Version|000.024.00020|
|Hardware Version|Hub v2 US|

Will that be OK?
When is version 0.87 due ?


#56

0.87 is out this week, I believe, and by native integration, I mean that you won’t have to use MQTT anymore. SmartThings is going to be integrated as a component within Home Assistant so you’ll be able to add your devices directly that way.


#57

hey @dustinthurston how did you manage to sort your docker compose?

I have followed your method and even before following the OP I keep getting Error: Connection Refused: Not Authorized in my portainer. The mqtt-bridge is not running at all.


#58

is your mqtt-bridge working in your docker container?


#59

Is it a cloud based integration or local ?


#60

Looking here:

it says “SmartThings Cloud integration for Home Assistant.” in init.py