Has anyone been successful with any of the guides that walk you through the integration in Hassio?
Iâm not sure yet how to get started as itâs command line based and Iâm not very familiar with linux⌠but Iâm hoping to attempt this.
Did you still need help with this?
Iâm new I did mqtt configuration to all in one home assistant, Iâm just wondering it it the same processes, I do have SmartThings adon installed. What I have do next
Iâm writing a long tutorial on how to do this specifically a Raspberry Pi w/ Hassio installed, and the Hass.io plugins MQTT Broker and Vkornâs SmartThings Bridge. Stay tuned!
As I was writing the tutorial, I figured out the issue why my door sensors werenât communicating to HA. I wasnât paying attention to case sensitivityâŚ
This tutorial is for those using a Raspberry Pi with Hass.io, and the Hass.io add-ons: Mosquitto broker (included in default repository), and SmartThingsBridge (from vkornâs repository). There are other tutorials out there, but not specifically using the items listed above. Iâll continue editing this post for corrections/cleanup.
For a basic understanding of how the communications works from Smartthings to Home Assistant and vice versa, check out this image posted on the HA blog. It wonât make sense now, but should later on. We are creating the Bridge SmartApp (in SmartThings), Device Type (in SmartThings), Rest Bridge (in HA), and Broker (in HA) in this tutorial.
1) Install the Mosquitto (MQTT) Broker Hass.io add-on
Connect to your Home Assistant frontend using a web browser (e.g. http://hassio.local:8123)
- From the Sidebar (click on the 3 horizontal lines in upper left corner), go to Hass.io>>Store icon>>Mosquitto broker add-on>>Open>>Install
- Donât touch the Options or the Network settings of the MQTT broker add-on. Ports should be 1883 and 8883. Here are my default settings:
{ "plain": true, "ssl": false, "anonymous": true, "logins": [], "customize": { "active": false, "folder": "mosquitto" }, "certfile": "fullchain.pem", "keyfile": "privkey.pem" }
- The default port of Mosquitto Broker is 1883âthe SmartThingsBridge add-on will need to connect to this port. Check that this port is listed correctly in the SmartThings Bridge add-on options.
- Make sure the add-on is installed correctly by checking the state and logs for any errors. You can see the state and logs when you view the add-onâs info from the Hass.io section of the Sidebar.
2) Install the SmartThingsBridge Hass.io add-on from Vladâs (vkorn) repository
- Connect to your Home Assistant frontend using a web browser (e.g. http://hassio.local:8123)
- From the Sidebar (click on the 3 horizontal lines in upper left corner), go to Hass.io>>Store icon
- In the section âAdd-on Repositoriesâ, add the repository âGitHub - vkorn/hassio-addons: Hass.io add-onsâ and click âsaveâ
- A new section called âVladâs repositoryâ should appear and you should see his SmartThingsBridge hass.io add-on. Click on it, open, and install.
- In the SmartThingsBridge add-on options, leave everything as default. If you installed the Mosquitto Broker Hass.io add-on, the MQTT broker default port should be 1883 and the MQTT bridge port 2080. Here are my default options:
{ "broker_host": "172.17.0.1", "broker_port": 1883, "preface": "smartthings", "state_suffix": "state", "command_suffix": "cmd", "login": "login", "password": "password", "bridge_port": 2080 }
- Make sure the bridgeâs default port is 2080âthe SmartThings device will need to connect to this port. You will need to make sure this port is listed correctly in the SmartThings device.
- Note: I am not sure what the âbroker_host: 172.17.0.1â in the Options means. I left it as-is because I was able to connect the broker and bridge using these default settings.
3) Create the Smartthings Device Handler and Device
- Follow the steps in this tutorial, starting at the section âSMARTTHINGS DEVICEâ
- I named my device handler as 'MQTT Bridge Device Handler and my device as âMQTT Bridge Deviceâ
- Double-check the preferences of your newly created Smartthings Device. You can edit the IP address and port, which should be the local IP address of the RPi hosting HA, and the port 2080, if youâve been following my instructions.
- I had issues creating a SmartThings device because I could not fill out the device sections âLocationâ and âHubâ. You should have registered your Smartthings hub by now and it should show up under the âMy Locationsâ tab. My hub was registered, but it wasnât showing up properly in the âMy Hubsâ section. To fix this, I clicked on âMy Locationsâ, my hub, then on âList Devicesâ. Once I navigated here, I clicked on âMy Devicesâ at the top section and was able to see my hub and devices. I was able to add a new device with the location and hub drop-down menu properly showing my Smartthings hub. It will just magically work one of these days.
4) Create the Smartthings SmartApp
-
Follow the steps in this tutorial (BUT ALSO SEE MY NOTES BELOW), starting at the section âSMARTTHINGS APPâ. Stop after youâve completed that section and return to this tutorial.
-
One difference in the tutorial you will need to change is that the MQTT bridge port you use is 1883, not 8080. We are using a different MQTT broker than what is used in the linked tutorial.
5) Add the SmartApp to your Smartthings instance
- This step is briefly described in the tutorial, but here are the specific instructions to follow in the mobile app:
- Open Smartthings mobile app, click on Automation icon (looks like a house) >> SmartApps >> Add a SmartApp >> My Apps >> MQTT Bridge SmartApp (whatever you named it)
- I named my SmartApp as âMQTT Bridge SmartAppâ
- In the Inputs section when adding the SmartApp, select the inputs and the supported devices that you want to communicate to Home Assistant. I did not select any Philips Hue light bulbs since HA does a great job connecting to the Philips Hue bridge.
6) Edit the HA configuration.yaml file to enable the MQTT broker
mqtt: broker: localhost discovery: true discovery_prefix: smartthings
- Iâve read forum comments saying that using âlocalhostâ should be fine. The tutorial says replace it with the location of the broker. You may need to experiment with this if things arenât working for you.
7) Reboot and check if things are working
-
My preferred method to reboot is to go to the Dashboard >>Hass.io >> 3 dots button >> Restart Home Assistant
-
In the MQTT broker logs, do you see ânew connectionâ and ânew client connectedâ? If so, that means the SmartThingsBridge is communicating to the broker
-
In the SmartThingsBridge logs, do you see entries like âSaving current stateâ, âSubscribing toâŚâ or âIncoming message from SmartThingsâŚâ? If so, then SmartThings is communicated to the SmartThingsBridge.
8) Add your sensors to Home Assistant configuration.yaml
-
In my example, I am adding a Z-Wave door/window sensor that reports open/closed. We will use a MQTT binary sensor to represent this in HA. Other sensors can report more than on/off and you will need to use the correct MQTT sensor in your configuration.yaml. Look at the related components on this page to see the different MQTT sensors.
-
Find the names of your sensors by viewing the SmartThingsBridge logs at Dashboard >> Hass.io >> SmartThingsBridge >> Logs
-
You can also change the logger level in your configuration.yaml to show MQTT activity logs. Look up Logger component documentation for more info. My configuration.yaml looks like this:
logger:
default: critical
logs:
homeassistant.components.mqtt: debug -
If you have a door/window sensor, open and close your doors (in real life), and then see if the SmartThingsBridge logs detected the action. In my logs, I saw âIncoming message from SmartThings: smartthings/Front Door Sensor/contact/state = openâ
-
NOTE: this is case-sensitive! Open != open. Use the exact case listed in the logs when you create your sensors in configuration.yaml.
-
Create a section called in the configuration.yaml called âbinary_sensorâ. See below:
binary_sensor: - platform: mqtt name: "Fridge Door" state_topic: "smartthings/Fridge Door/contact/state" payload_on: "open" #This is case sensitive! payload_off: "closed" #This is case sensitive! device_class: opening #Your sensor will read as open/closed instead of on/off with this setting retain: true #this is important so HA doesn't report the sensor as disconnected
Super helpful! Thanks so much for a clear and concise walk through.
Where were you when I tried setting this up a week ago?! Setting the port number in the device in SmartThings to match the bridge_port in the Bridge configuration was the piece I was missing and didnât find that anywhere else.
Thank you!!
OP here. I was able to resolve my issue a few days after creating this post. The problem was my MAC address. I tried getting it from running ifconfig
on the Pi and the MAC address it was returning was for Docker and not the actual Pi. Itâs been so long now that I canât remember the way of getting the real MAC from the Pi but Iâm sure someone can chime in with that answer.
I didnât read the tutorial that was posted above but it sounds like its already helping people so Iâm super happy abut that! Good luck to everyone and just know that it IS possible to get working!
lol, last week I was also trying to figure it out. After reading through the tutorials, I eventually learned that the tutorials I read were correct for their specific configurations, but not mine (Hassio install and Hassio plugins). The other tutorials used a different MQTT broker and bridge default settings, so I eventually traced back the errors to the port numbers used. Tutorials are helpful but we shouldnât be too dependent on them if we really want to understand HAâŚ
I also read somewhere and learned why the Hassio MQTT broker plugin options lists ports 1883 and 8883. Port 8883 is used if SSL is enabled, 1883 if SSL is disabled. I would love to know if anyone was able to turn on SSL with the broker!
Hi dwinn,
Thank you for the time and effort on this tutorial. Iâm new to HA and I have been looking out a method for integrating smartthings with HA. I found yours and I followed your step to setup! As you mentioned, sanity checks like for MQTT broker connection shows starting version 3.2.2
1513692029: mosquitto version 1.4.12 (build date 2017-06-01 13:03:48+0000) starting
1513692029: Config loaded from /etc/mosquitto.conf.
1513692029: Opening ipv4 listen socket on port 1883.
1513692029: Opening ipv6 listen socket on port 1883.
1513692029: Warning: Mosquitto should not be run as root/administrator.
1513692029: New connection from 172.30.32.1 on port 1883.
1513692029: New client connected from 172.30.32.1 as 41d3ef5e-de10-4b4f-8a80-1f89349e6bf3 (c1, k60).
1513692919: New connection from 10.0.10.11 on port 1883.
1513692919: Socket error on client , disconnecting.
and similarly SmartThings Bridge logs also show info: Saving current state
info: Connecting to MQTT at mqtt://172.17.0.1:8888.
Does it seem right? I did add the switches in the Configuration.yaml file and after restart the I see switches on the homescreen but doesnât work. Could you please help me on this issue?
Thank you
Double check the ports you defined. I never used port 8888 in my tutorial, but your logs show that the Smartthings Bridge is trying to connect to the broker at port 8888.
Well done guide!
Might I ask if you have a few examples of a light and a switch perhaps?
I finally bought some Sengled Zigbee light bulbs on sale from Amazon and added them to SmartThings and HA. If your bulb supports RGB, then you need to add more parameters than what is listed here. I donât fully understand the âoptimisticâ variable, but it was used in an example. Here is what you should write in your configuration.yaml file.
EDIT 1/13/2018: I didnât fully test this config and realized
that turning on/off and changing brightness doesnât work from HA, but on/off states are reported correctly. Anyone else have this problem or a solution?
light:
- platform: mqtt
name: "Bedroom Light"
state_topic: "smartthings/Bedroom Light/switch/state"
command_topic: "smartthings/Bedroom Light/switch/cmd"
brightness_command_topic: "smartthings/Bedroom Light/level/cmd"
brightness_state_topic: "smartthings/Bedroom Light/level/state"
payload_off: "off"
payload_on: "on"
optimistic: false
Great guide!! It was pretty easy to follow and seems that everything is working. I do have a little issue in that when I look at my logs for the plugins I see messages that look like things are working but I do not see anything about the actual devices or device names so I donât know how to create them in HASSIO so I can see them and use them.
In the MQ Broker I see these kind of messages:
New Connection from 172.x.x.x on port 1883.
New Client connected from 172.x.x.x as 89xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx (c1, k60).
Saving in-memory database to /data/mosquitto.db.
Saving in-memory database to /data/mosquitto.db.
Saving in-memory database to /data/mosquitto.db.
In the SmartThingsBridge logs:
Loading configuration
Loading previous state
Connecting to MQTT at mqtt://172.17.0.1:1883
Configuring autosave
Configuring API
Listening at http://localhost:2080
Saving current state
Saving current state
Saving current state
etcâŚ
This tutorial is EXACTLY what I needed. I am a newbie to all of this and currently use SmartThings, Webcore, and ActionTiles for home automation, but have an extra RPi and decided to try out HA.
Are there any good examples out there of configuration.yaml entries for different devices?
I wonder if you didnât configure the Smartthings MQTT bridge app correctly. You have to open the Smartthings app on your phone/tablet, navigate to the MQTT smartapp you created, then make sure you added all your sensors and switches in every setting (battery, contact sensor, switch level, etc). Then generate some activity on your sensor by opening/closing a door, and check your logs for the SmartBridge add-on.
I deleted all the smartthings pieces and recreated them and now itâs working. Thanks!