Smarter SmartThings with MQTT and Home Assistant


#21

yes, all those that i want are ticked.


#22

I was never able to get automatic discovery working. I manually added all my devices. It felt like a lot of work at the time but I’m really a lot happier controlling everything in home Assistant.

All the devices and their states show up every time you subscribe to the topic in another mqtt utility which is helpful.


#23

It doesn’t support MQTT Discovery.


#24

Went thru the same thing last night trying to figure it out. I did delete MQTT Configuration from my Home assistant configuration file. Deleted the username/password from Mosquito MQTT add-on but had to add all my devices back in to binary_sensor.yaml file to get them to show up. They will not get discovered.


#25

So, if we’re concluding that it can’t discover them, @hongtat what was the mqtt utility you used to see all the devices and states?


#26

You have to add the Smarthings devices into HASS manually.

For example: I have a contact sensor “Main Door” in ST, I have to add this in HASS -

- platform: mqtt
  name: "Main Door Contact"
  state_topic: "smartthings/Main Door/contact"
  retain: true
- platform: mqtt
  name: "Main Door Contact Temperature"
  state_topic: "smartthings/Main Door/temperature"
  unit_of_measurement: '°C'
  retain: true
- platform: mqtt
  name: "Main Door Contact Battery"
  state_topic: "smartthings/Main Door/battery"
  unit_of_measurement: "%"
  retain: true

#27

but how did you know that unit_of_measurement was the syntax to use for that device?


#28

You can find them in ST.
Temperature is either C or F.
Battery is usually in %.


#29

Regarding your question about how to see the device states, I use the mqtt command line tools in the terminal. I’m using mosquitto, so I type the following:

mosquitto_sub -h localhost -v -t smartthings/#

Make sure to change “localhost” to the ip address of you mqtt server. That should print all of your devices and their current state assuming you didn’t uncomment the retain: false line in the mqtt config.


#30

Figuring out the syntax for different devices took me a while. Often I dug through other peoples config examples until I found the hardware I needed to copy. These might be helpful:



#31

I got a SmartThings hub recently. I have lights and water sensors integrated in via the native app at present.

I’ve been working through getting the mqtt-bridge/smartapp/device handler working for HA integration.

All are running on a single host as docker instances;

I have setup HA, mosquitto as my mqtt-broker, configured HA with mqtt and one light, and configured the mqtt-st-bridge container. Everything up to that point appears to be running fine;

From mosquitto / mqtt-broker I see:

1544115808: New connection from 192.168.1.40 on port 1883.
1544115808: New client connected from 192.168.1.40 as 1ec789e6-1e69-4a26-8eb1-5668be164dde (c1, k60).
1544116003: Socket error on client mqttjs_9af5c13f, disconnecting.
1544116004: New connection from 192.168.1.40 on port 1883.
1544116004: New client connected from 192.168.1.40 as mqttjs_432703d4 (c1, k10).
1544116902: Saving in-memory database to /mosquitto/data/mosquitto.db.

The mqtt-st-bridge is listening on 8081 as I have an ubiquiti dockerized service running on 8080 right now.

info: Starting SmartThings MQTT Bridge - v3.0.0
info: Loading configuration
info: Loading previous state
info: Perfoming configuration migration
info: Saving current state
info: Connecting to MQTT at mqtt://192.168.1.40
info: Configuring autosave
info: Configuring API
info: Listening at http://localhost:8081
info: Saving current state
info: Saving current state

The one challenge I’m seeing is after adding the mqtt bridge Device in the Smartthings IDE it seems to be stuck in “Active” and not “Online” and I never see the ST Hub establish a link to the mqtt-st-bridge;

EDIT: apparently I can only put one image in a post, so take my word on the “Active” vs “Online” in the IDE, but we can see that you cannot see any connections to the local docker on 8081 below:

$docker exec -it mqtt-st-bridge /bin/sh
/usr/src/app # netstat -an | grep 8081
tcp        0      0 :::8081                 :::*                    LISTEN 
 
/usr/src/app # ifconfig | grep -e "inet addr\|HWaddr"
<snip>
ens160    Link encap:Ethernet  HWaddr 00:0C:29:0F:98:A0  
          inet addr:192.168.1.40  Bcast:192.168.1.255  Mask:255.255.255.0
          inet addr:127.0.0.1  Mask:255.0.0.0

I have it properly configured with the IP address, port and MAC
52%20PM

How can I troubleshoot the connection between the ST hub and the mqtt-st-bridge? I see no logs from the Smartthings IDE, and the only Events on the mqtt-device I created is the original creation message.


#32

Seeing if I can post my other image from the ST IDE where it shows “Active” only:


#33

Hello, is there a way to configure the bridge in a way so it pushes the state for every device in ST every x minutes? Would be useful for instances where something happens and the retained states are lost (and also for devices that have batteries and you’d have to wait until the percentage drops to know their value so you can configure them).


#34

hello have you ever tried the samsung wifi air conditioners?


#35

Should I be seeing anything in the MQTT logs when a Smartthings sensor is opened/closed? I’m now seeing it in the logs of the ST bridge as well as the <> portion of HA, but not quite sure what to do next lol.


#36

Are you seeing states updating the dev-states portion? If you’re seeing things update in there as well as the ST Bridge Logs, you should be pretty much ready to go.


#37

I am seeing activities in the dev-states, so now I guess I just need to figure out what to do with this MQTT stuff :slight_smile:


#38

Might be overthinking it then. If you set the Status and Command states properly and you’re seeing updates, it sounds like you only need to send commands from HA and see if it properly updates to ST. MQTT is more of in the background rather than front facing.