mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-22 00:36:49 +00:00
Fix markup smartthings blogpost
This commit is contained in:
parent
ec381cf5de
commit
e0a7550715
@ -1,29 +1,33 @@
|
||||
---
|
||||
layout: post
|
||||
title: "Smarter Smart Things with MQTT and Home Assistant"
|
||||
title: "Smarter SmartThings with MQTT and Home Assistant"
|
||||
description: "Jer and St. John describe how they connected SmartThings with Home Assistant."
|
||||
date: 2016-02-09 10:10 -0700
|
||||
date: 2016-02-09 0:44 -0700
|
||||
date_formatted: "February 09, 2016"
|
||||
author: Jeremiah Wuenschel and St. John Johnson
|
||||
comments: true
|
||||
categories: User-Stories
|
||||
og_image: /images/blog/2016-02-09-Smarter-Smart-Things-with-MQTT-and-Home-Assistant.jpg
|
||||
categories: How-To MQTT
|
||||
og_image: /images/blog/2016-02-smartthings/social.png
|
||||
---
|
||||
|
||||
|
||||
_This is a guest post by Home Assistant users [Jeremiah Wuenschel](https://github.com/jer) and [St. John Johnson](https://github.com/stjohnjohnson)._
|
||||
|
||||
# SmartThings
|
||||
|
||||
So you own a [SmartThings][smartthings] Hub. You probably bought it when you were looking to get into the whole Home Automation hobby because it worked with pretty much everything and offered you the ability to automate __anything.__ After a week of ownership, you realized that building dashboards and automating required writing way more Groovy then you expected. Then one day you were browsing [reddit][r/homeautomation] and discovered the amazingness that is Home Assistant! A solution that offered dashboards, graphs, working support for Nest, and REAL EASY automation!
|
||||
|
||||
You spent your weekend getting everything set up, showing it off to your significant other, but in the end you got stumped when it came to integrating with all your existing SmartThings toys. What do I do now? Should I buy another hub? Should I just buy a z-wave stick?
|
||||
You spent your weekend getting everything set up, showing it off to your significant other, but in the end you got stumped when it came to integrating with all your existing SmartThings toys. What do I do now? Should I buy another hub? Should I just buy a Z-Wave stick?
|
||||
|
||||
That's where we came in. We wanted a solution that can bridge the awesomeness of Home Assistant with the SmartThings hub that works with almost everything.
|
||||
|
||||
<p class='img'>
|
||||
<img src='/images/blog/2016-02-smartthings/splash.png'>
|
||||
</p>
|
||||
|
||||
<!--more-->
|
||||
|
||||
## Glossary
|
||||
|
||||
This is going to be a pretty detailed tutorial on setting up our SmartThings bridge. However, there are a couple key terms that __might__ be new to you:
|
||||
This is going to be a pretty detailed tutorial on setting up our SmartThings bridge. However, there are a couple key terms that _might_ be new to you:
|
||||
|
||||
- [MQTT][mqtt]: A lightweight message protocol for listening and publishing events that happen. Many home automation platforms have built in support for this [(especially Home Assistant)][mqtt-ha].
|
||||
- [Docker][docker]: A tool for running applications that are self-contained. No need for installing any dependencies or worrying about conflicts. Installs easily on Linux and OSX.
|
||||
@ -36,27 +40,31 @@ Assuming that you already have Home Assistant and Smart Things running, you will
|
||||
|
||||
There is very little you need to do to get Mosca running. The easiest approach is to use [Docker][docker], and run a command like the following:
|
||||
|
||||
$ docker run \
|
||||
-d \
|
||||
--name="mqtt" \
|
||||
-v /opt/mosca:/db \
|
||||
-p 1883:1883 \
|
||||
matteocollina/mosca
|
||||
```bash
|
||||
$ docker run \
|
||||
-d \
|
||||
--name="mqtt" \
|
||||
-v /opt/mosca:/db \
|
||||
-p 1883:1883 \
|
||||
matteocollina/mosca
|
||||
```
|
||||
|
||||
This will start Mosca up inside of a docker container, while keeping persistent storage for Mosca in `/opt/mosca`. The default configuration is the only thing we need to get things up and running.
|
||||
|
||||
If you don't want to mess with Docker and can get node.js installed without trouble, the [Standalone][mosca-standalone] instructions are all you need.
|
||||
If you don't want to mess with Docker and can get node.js installed without trouble, the [standalone][mosca-standalone] instructions are all you need.
|
||||
|
||||
### MQTT Bridge
|
||||
|
||||
This is the small piece of magic that bridges the gap between MQTT and SmartThings. It is a node.js app, and like Mosca it is probably easiest to install with Docker:
|
||||
|
||||
$ docker run \
|
||||
-d \
|
||||
--name="mqtt-bridge" \
|
||||
-v /opt/mqtt-bridge:/config \
|
||||
-p 8080:8080 \
|
||||
stjohnjohnson/smartthings-mqtt-bridge
|
||||
```bash
|
||||
$ docker run \
|
||||
-d \
|
||||
--name="mqtt-bridge" \
|
||||
-v /opt/mqtt-bridge:/config \
|
||||
-p 8080:8080 \
|
||||
stjohnjohnson/smartthings-mqtt-bridge
|
||||
```
|
||||
|
||||
The code for this bridge is [on Github][mqtt-bridge] if you want to start it up independently.
|
||||
|
||||
@ -70,7 +78,9 @@ mqtt:
|
||||
|
||||
Restart the bridge, and you are ready to go:
|
||||
|
||||
$ docker restart mqtt-bridge
|
||||
```bash
|
||||
$ docker restart mqtt-bridge
|
||||
```
|
||||
|
||||
### SmartThings Device
|
||||
|
||||
@ -80,9 +90,9 @@ Now to install your new Device Handler. Go back to `My Devices` in the IDE, and
|
||||
|
||||
Go back to `My Devices`, and click on your new device in the list. This will bring up a page that allows you to edit your device's Preferences. Click `edit` and fill in the 3 pieces of information it asks for.
|
||||
|
||||
MQTT Bridge IP Address: <IP address of the MQTT Bridge from the previous step>
|
||||
MQTT Bridge Port: <8080 if you have changed nothing in the previous commands>
|
||||
MQTT Bridge MAC Address: <Mac address of whatever machine is running the Bridge code>
|
||||
- MQTT Bridge IP Address: \<IP address of the MQTT Bridge from the previous step>
|
||||
- MQTT Bridge Port: \<8080 if you have changed nothing in the previous commands>
|
||||
- MQTT Bridge MAC Address: \<Mac address of machine running the Bridge code>
|
||||
|
||||
This will create the link between SmartThings and the MQTT Bridge.
|
||||
|
||||
@ -105,10 +115,10 @@ Replace `localhost` with the location of the running MQTT Broker. Devices from t
|
||||
|
||||
For example, my Dimmer Z-Wave Lamp is called "Fireplace Lights" in SmartThings. The following topics are published:
|
||||
|
||||
# Brightness (0-99)
|
||||
/smartthings/Fireplace Lights/level
|
||||
# Switch State (on|off)
|
||||
/smartthings/Fireplace Lights/switch
|
||||
| Topic | Description
|
||||
| ----- | -----------
|
||||
| /smartthings/Fireplace Lights/level | Brightness (0-99)
|
||||
| /smartthings/Fireplace Lights/switch | Switch State (on/off)
|
||||
|
||||
Here is an example Home Assistant config:
|
||||
|
||||
@ -131,9 +141,7 @@ Start digging through the [MQTT Components][mqtt-ha] in Home Assistant to find w
|
||||
|
||||
### Configuring with Docker-Compose
|
||||
|
||||
Our personal preference for starting the whole suite of software is to use a single Docker-Compose file.
|
||||
|
||||
Just create a file called docker-compose.yml like this:
|
||||
Our personal preference for starting the whole suite of software is to use a single Docker-Compose file. Just create a file called `docker-compose.yml` like this:
|
||||
|
||||
```yaml
|
||||
mqtt:
|
||||
@ -168,7 +176,8 @@ This will start home-assistant, MQTT, and the Bridge, in dependency order. All c
|
||||
**HTTP Endpoint**: There are really only 2 ways to communicate with the SmartThings hub that we could find. The easiest approach is to create a RESTful SmartApp authenticated with OAuth that provides state changes via HTTP directly. This approach is pretty straightforward to implement, but it requires communication with the SmartThings cloud service, and can't be done entirely on your LAN. We hoped to keep all communication internal, and came up with a second approach.
|
||||
|
||||
**Custom Device Type:** SmartThings custom device types allow developers to define handlers for HTTP events received directly over the local network by the SmartThings hub. Messages received are authenticated by MAC address, and can contain arbitrary strings in their payload. Since a Device Type is only ever tied to a single device, we need to add a SmartApp to the mix in order to translate events between individual devices and our special Home Assistant Bridge device. Here is what we have so far:
|
||||
```
|
||||
|
||||
```text
|
||||
Z-Wave Switch |
|
||||
Zigbee motion sensor |<---> Bridge App <---> Bridge Device Type <---> <Local network>
|
||||
Z-Wave light bulb |
|
||||
@ -178,7 +187,13 @@ On the Home Assistant side, there is a powerful platform available based on the
|
||||
|
||||
Here is the final sequence of events:
|
||||
|
||||

|
||||
<p class='img'>
|
||||
<a href='/images/blog/2016-02-smartthings/SmartThings-HomeAssistant.png'>
|
||||
<img src='/images/blog/2016-02-smartthings/SmartThings-HomeAssistant.png' alt='SmartThings Bridge Sequence'>
|
||||
</a>
|
||||
SmartThings Bridge Sequence
|
||||
</p>
|
||||
|
||||
|
||||
There are a lot of stops along the way for these events, but each piece is a simple translation layer to shuttle the events between systems.
|
||||
|
||||
@ -198,7 +213,7 @@ There are a lot of stops along the way for these events, but each piece is a sim
|
||||
[devicetype]: https://github.com/stjohnjohnson/smartthings-mqtt-bridge/blob/master/devicetypes/stj/mqtt-bridge.src/mqtt-bridge.groovy
|
||||
[ide-app]: https://graph.api.smartthings.com/ide/apps
|
||||
[smartapp]: https://github.com/stjohnjohnson/smartthings-mqtt-bridge/blob/master/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy
|
||||
[mqtt-ha]: https://home-assistant.io/components/mqtt/
|
||||
[mqtt-ha]: /components/mqtt/
|
||||
[smartthings]: http://smartthings.com
|
||||
[r/homeautomation]: https://www.reddit.com/r/homeautomation
|
||||
[mqtt]: https://en.wikipedia.org/wiki/MQTT
|
||||
|
BIN
source/images/blog/2016-02-smartthings/social.png
Normal file
BIN
source/images/blog/2016-02-smartthings/social.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
BIN
source/images/blog/2016-02-smartthings/splash.png
Normal file
BIN
source/images/blog/2016-02-smartthings/splash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
BIN
source/images/supported_brands/smartthings.png
Normal file
BIN
source/images/supported_brands/smartthings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
Loading…
x
Reference in New Issue
Block a user