home-assistant.github.io/blog/2016/02/09/Smarter-Smart-Things-with-MQTT-and-Home-Assistant/index.html
2016-12-06 08:23:42 +00:00

465 lines
No EOL
25 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Smarter SmartThings with MQTT and Home Assistant - Home Assistant</title>
<meta name="author" content="Jeremiah Wuenschel and St. John Johnson">
<meta name="description" content="Jer and St. John describe how they connected SmartThings with Home Assistant.">
<meta name="viewport" content="width=device-width">
<link rel="canonical" href="https://home-assistant.io/blog/2016/02/09/Smarter-Smart-Things-with-MQTT-and-Home-Assistant/">
<meta property="fb:app_id" content="338291289691179">
<meta property="og:title" content="Smarter SmartThings with MQTT and Home Assistant">
<meta property="og:site_name" content="Home Assistant">
<meta property="og:url" content="https://home-assistant.io/blog/2016/02/09/Smarter-Smart-Things-with-MQTT-and-Home-Assistant/">
<meta property="og:type" content="article">
<meta property="og:description" content="Jer and St. John describe how they connected SmartThings with Home Assistant.">
<meta property="og:image" content="https://home-assistant.io/images/blog/2016-02-smartthings/social.png">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@home_assistant">
<meta name="twitter:title" content="Smarter SmartThings with MQTT and Home Assistant">
<meta name="twitter:description" content="Jer and St. John describe how they connected SmartThings with Home Assistant.">
<meta name="twitter:image" content="https://home-assistant.io/images/blog/2016-02-smartthings/social.png">
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet">
<link href="/atom.xml" rel="alternate" title="Home Assistant" type="application/atom+xml">
<link rel='shortcut icon' href='/images/favicon.ico' />
<link rel='icon' type='image/png' href='/images/favicon-192x192.png' sizes='192x192' />
</head>
<body >
<header>
<div class="grid-wrapper">
<div class="grid">
<div class="grid__item three-tenths lap-two-sixths palm-one-whole ha-title">
<a href="/" class="site-title">
<img width='40' src='/demo/favicon-192x192.png'>
<span>Home Assistant</span>
</a>
</div>
<div class="grid__item seven-tenths lap-four-sixths palm-one-whole">
<nav>
<input type="checkbox" id="toggle">
<label for="toggle" class="toggle" data-open="Main Menu" data-close="Close Menu"></label>
<ul class="menu pull-right">
<li><a href="/getting-started/">Getting started</a></li>
<li><a href="/components/">Components</a></li>
<li><a href="/ecosystem/">Ecosystem</a></li>
<li><a href="/cookbook/">Examples</a></li>
<li><a href="/developers/">Developers</a></li>
<li><a href="/blog/">Blog</a></li>
<li><a href="/help/">Need help?</a></li>
</ul>
</nav>
</div>
</div>
</div>
</header>
<div class="grid-wrapper">
<div class="grid grid-center">
<div class="grid__item two-thirds lap-one-whole palm-one-whole">
<article class="post">
<header>
<h1 class="title indent">Smarter SmartThings with MQTT and Home Assistant</h1>
<div class="meta clearfix">
<time datetime="2016-02-09T07:44:00+00:00" pubdate data-updated="true"><i class="icon-calendar"></i> February 09, 2016</time>
<span class="byline author vcard"><i class='icon-user'></i> Jeremiah Wuenschel and St. John Johnson</span>
<span><i class='icon-time'></i> nine minutes reading time</span>
<span>
<i class="icon-tags"></i>
<ul class="tags unstyled">
<li>How-To</li>
<li>MQTT</li>
</ul>
</span>
<a class='comments'
href="#disqus_thread"
>Comments</a>
</div>
</header>
<p><em>This is a guest post by Home Assistant users <a href="https://github.com/jer">Jeremiah Wuenschel</a> and <a href="https://github.com/stjohnjohnson">St. John Johnson</a>.</em></p>
<p>So you own a <a href="http://smartthings.com">SmartThings</a> 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 <strong>anything.</strong> 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 <a href="https://www.reddit.com/r/homeautomation">reddit</a> and discovered the amazingness that is Home Assistant! A solution that offered dashboards, graphs, working support for Nest, and REAL EASY automation!</p>
<p>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?</p>
<p>Thats 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>
<p class="img">
<img src="/images/blog/2016-02-smartthings/splash.png" />
</p>
<a name="read-more"></a>
<h2>Glossary</h2>
<p>This is going to be a pretty detailed tutorial on setting up our SmartThings bridge. However, there are a couple key terms that <em>might</em> be new to you:</p>
<ul>
<li><a href="https://en.wikipedia.org/wiki/MQTT">MQTT</a>: A lightweight message protocol for listening and publishing events that happen. Many home automation platforms have built in support for this <a href="/components/mqtt/">(especially Home Assistant)</a>.</li>
<li><a href="https://www.docker.com/">Docker</a>: 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.</li>
</ul>
<h2>Setting up the Bridge</h2>
<h3>MQTT</h3>
<p>Assuming that you already have Home Assistant and Smart Things running, you will first want to get an MQTT broker running. There are a handful of <a href="http://mosquitto.org/">MQTT</a> <a href="https://github.com/emqtt/emqttd">brokers</a> available in Open Source land. We chose <a href="http://www.mosca.io/">Mosca</a> for its simplicity.</p>
<p>There is very little you need to do to get Mosca running. The easiest approach is to use <a href="https://www.docker.com/">Docker</a>, and run a command like the following:</p>
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>docker run <span class="se">\</span>
-d <span class="se">\</span>
--name<span class="o">=</span><span class="s2">"mqtt"</span> <span class="se">\</span>
-v /opt/mosca:/db <span class="se">\</span>
-p 1883:1883 <span class="se">\</span>
matteocollina/mosca
</code></pre>
</div>
<p>This will start Mosca up inside of a docker container, while keeping persistent storage for Mosca in <code class="highlighter-rouge">/opt/mosca</code>. The default configuration is the only thing we need to get things up and running.</p>
<p>If you dont want to mess with Docker and can get node.js installed without trouble, the <a href="https://github.com/mcollina/mosca#standalone">standalone</a> instructions are all you need.</p>
<h3>MQTT Bridge</h3>
<p>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:</p>
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>docker run <span class="se">\</span>
-d <span class="se">\</span>
--name<span class="o">=</span><span class="s2">"mqtt-bridge"</span> <span class="se">\</span>
-v /opt/mqtt-bridge:/config <span class="se">\</span>
-p 8080:8080 <span class="se">\</span>
stjohnjohnson/smartthings-mqtt-bridge
</code></pre>
</div>
<p>The code for this bridge is <a href="https://github.com/stjohnjohnson/smartthings-mqtt-bridge">on Github</a> if you want to start it up independently.</p>
<p>The MQTT Bridge only needs to know where your MQTT broker lives. If you are using these docker commands as-is, edit <code class="highlighter-rouge">/opt/mqtt-bridge/config.yml</code> to look like this:</p>
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="nn">---</span>
<span class="s">mqtt</span><span class="pi">:</span>
<span class="s">host</span><span class="pi">:</span> <span class="s">&lt;IP of the host&gt;</span>
</code></pre>
</div>
<p>Restart the bridge, and you are ready to go:</p>
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>docker restart mqtt-bridge
</code></pre>
</div>
<h3>SmartThings Device</h3>
<p>The next step (and possibly the most confusing) is the device type. Go to the <a href="https://graph.api.smartthings.com/ide/devices">Smart Things Device IDE</a> and <code class="highlighter-rouge">Create New Device Handler</code>. Choose <code class="highlighter-rouge">From Code</code> and paste in the <a href="https://github.com/stjohnjohnson/smartthings-mqtt-bridge/blob/master/devicetypes/stj/mqtt-bridge.src/mqtt-bridge.groovy">MQTT Bridge Device Code</a>. Click <code class="highlighter-rouge">Save</code>, <code class="highlighter-rouge">Publish</code>, and then <code class="highlighter-rouge">For Me</code>.</p>
<p>Now to install your new Device Handler. Go back to <code class="highlighter-rouge">My Devices</code> in the IDE, and click <code class="highlighter-rouge">New Device</code>. Enter a name, and pick any random set of characters for the Device Network Id (this will automatically update later). For Type, scroll to the bottom of the list and find your newly created <code class="highlighter-rouge">MQTT Bridge</code>. Fill in the other boxes however you like.</p>
<p>Go back to <code class="highlighter-rouge">My Devices</code>, and click on your new device in the list. This will bring up a page that allows you to edit your devices Preferences. Click <code class="highlighter-rouge">edit</code> and fill in the 3 pieces of information it asks for.</p>
<ul>
<li>MQTT Bridge IP Address: &lt;IP address of the MQTT Bridge from the previous step&gt;</li>
<li>MQTT Bridge Port: &lt;8080 if you have changed nothing in the previous commands&gt;</li>
<li>MQTT Bridge MAC Address: &lt;Mac address of machine running the Bridge code&gt;</li>
</ul>
<p>This will create the link between SmartThings and the MQTT Bridge.</p>
<h3>SmartThings App</h3>
<p>The last step is to setup the SmartApp. After this, any registered devices will start sending their events to MQTT.</p>
<p>Go to the <a href="https://graph.api.smartthings.com/ide/apps">Smart App IDE</a>. Click <code class="highlighter-rouge">New SmartApp</code>, followed by <code class="highlighter-rouge">From Code</code>. Paste in the <a href="https://github.com/stjohnjohnson/smartthings-mqtt-bridge/blob/master/smartapps/stj/mqtt-bridge.src/mqtt-bridge.groovy">MQTT Bridge SmartApp code</a> and click <code class="highlighter-rouge">Save</code>. Click <code class="highlighter-rouge">Publish</code> and then <code class="highlighter-rouge">For Me</code>. In the SmartThings mobile app, add the new SmartApp and configure it with your devices and MQTT Bridge device. Clicking <code class="highlighter-rouge">done</code> will subscribe SmartThings to your MQTT broker and begin 2-way propagation of events.</p>
<h3>Configure Home Assistant</h3>
<p>To add SmartThings devices to Home Assistant over MQTT, first enable MQTT in Home Assistant:</p>
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">mqtt</span><span class="pi">:</span>
<span class="s">broker</span><span class="pi">:</span> <span class="s">localhost</span>
</code></pre>
</div>
<p>Replace <code class="highlighter-rouge">localhost</code> with the location of the running MQTT Broker. Devices from the MQTT Bridge are published to the path <code class="highlighter-rouge">smartthings/&lt;Device Name&gt;/&lt;Atribute&gt;</code></p>
<p>For example, my Dimmer Z-Wave Lamp is called “Fireplace Lights” in SmartThings. The following topics are published:</p>
<table>
<thead>
<tr>
<th>Topic</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>smartthings/Fireplace Lights/level</td>
<td>Brightness (0-99)</td>
</tr>
<tr>
<td>smartthings/Fireplace Lights/switch</td>
<td>Switch State (on/off)</td>
</tr>
</tbody>
</table>
<p>Here is an example Home Assistant config:</p>
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">switch</span><span class="pi">:</span>
<span class="s">platform</span><span class="pi">:</span> <span class="s">mqtt</span>
<span class="s">name</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Fireplace</span><span class="nv"> </span><span class="s">Lights"</span>
<span class="s">state_topic</span><span class="pi">:</span> <span class="s2">"</span><span class="s">smartthings/Fireplace</span><span class="nv"> </span><span class="s">Lights/switch"</span>
<span class="s">command_topic</span><span class="pi">:</span> <span class="s2">"</span><span class="s">smartthings/Fireplace</span><span class="nv"> </span><span class="s">Lights/switch"</span>
<span class="s">brightness_state_topic</span><span class="pi">:</span> <span class="s2">"</span><span class="s">smartthings/Fireplace</span><span class="nv"> </span><span class="s">Lights/level"</span>
<span class="s">brightness_command_topic</span><span class="pi">:</span> <span class="s2">"</span><span class="s">smartthings/Fireplace</span><span class="nv"> </span><span class="s">Lights/level"</span>
<span class="s">payload_on</span><span class="pi">:</span> <span class="s2">"</span><span class="s">on"</span>
<span class="s">payload_off</span><span class="pi">:</span> <span class="s2">"</span><span class="s">off"</span>
<span class="s">retain</span><span class="pi">:</span> <span class="s">true</span>
</code></pre>
</div>
<p>We recommend <code class="highlighter-rouge">retain: true</code> for every MQTT device in order to keep states in sync when things become disconnected.</p>
<p>Start digging through the <a href="/components/mqtt/">MQTT Components</a> in Home Assistant to find which components map to the new events being published to MQTT.</p>
<h3>Configuring with Docker-Compose</h3>
<p>Our personal preference for starting the whole suite of software is to use a single Docker-Compose file. Just create a file called <code class="highlighter-rouge">docker-compose.yml</code> like this:</p>
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">mqtt</span><span class="pi">:</span>
<span class="s">image</span><span class="pi">:</span> <span class="s">matteocollina/mosca</span>
<span class="s">ports</span><span class="pi">:</span>
<span class="pi">-</span> <span class="s">1883:1883</span>
<span class="s">mqttbridge</span><span class="pi">:</span>
<span class="s">image</span><span class="pi">:</span> <span class="s">stjohnjohnson/smartthings-mqtt-bridge</span>
<span class="s">volumes</span><span class="pi">:</span>
<span class="pi">-</span> <span class="s">./mqtt-bridge:/config</span>
<span class="s">ports</span><span class="pi">:</span>
<span class="pi">-</span> <span class="s">8080:8080</span>
<span class="s">links</span><span class="pi">:</span>
<span class="pi">-</span> <span class="s">mqtt</span>
<span class="s">homeassistant</span><span class="pi">:</span>
<span class="s">image</span><span class="pi">:</span> <span class="s">homeassistant/home-assistant:latest</span>
<span class="s">ports</span><span class="pi">:</span>
<span class="pi">-</span> <span class="s">80:80</span>
<span class="s">volumes</span><span class="pi">:</span>
<span class="pi">-</span> <span class="s">./home-assistant:/config</span>
<span class="pi">-</span> <span class="s">/etc/localtime:/etc/localtime:ro</span>
<span class="s">links</span><span class="pi">:</span>
<span class="pi">-</span> <span class="s">mqtt</span>
</code></pre>
</div>
<p>This will start home-assistant, MQTT, and the Bridge, in dependency order. All config can reference the name of the docker container instead of using IP addresses (e.g. mqtt for the broker host in Home Assistant).</p>
<h3>How it works</h3>
<p><strong>HTTP Endpoint</strong>: 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 cant be done entirely on your LAN. We hoped to keep all communication internal, and came up with a second approach.</p>
<p><strong>Custom Device Type:</strong> 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:</p>
<div class="language-text highlighter-rouge"><pre class="highlight"><code>Z-Wave Switch |
Zigbee motion sensor |&lt;---&gt; Bridge App &lt;---&gt; Bridge Device Type &lt;---&gt; &lt;Local network&gt;
Z-Wave light bulb |
</code></pre>
</div>
<p>On the Home Assistant side, there is a powerful platform available based on the MQTT lightweight message bus protocol. Everything from lights to switches to temperature sensors can be defined in Home Assistant as an MQTT component, so it makes for a convenient integration point. This requires an MQTT broker for handling the message bus, and one last piece to translate between the HTTP that SmartThings supports and MQTT.</p>
<p>Here is the final sequence of events:</p>
<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>
<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.</p>
<h3>Future Improvements</h3>
<ul>
<li><strong>Raspberry pi</strong>: There is a lot of interest in getting this running on the Raspberry Pi. It only requires binaries compiled for ARM, so we plan to get ARM-compatible versions of the containers going at some point.</li>
<li><strong>Authentication for MQTT</strong>: At the moment, the MQTT bridge doesnt understand how to authenticate to MQTT, so only unauthenticated MQTT is supported. This is mitigated to some degree if you use our Docker Compose config, because MQTTs port is not actually shared publicly.</li>
<li><strong>Authentication for MQTT Bridge</strong>: Right now the bridge expects that anyone subscribing is the SmartThings hub. This could use proper authentication.</li>
</ul>
</article>
<section id="disqus">
<h3 class="indent title">Comments</h3>
<div id="disqus_thread" aria-live="polite"><noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript></div>
</section>
</div>
<aside id="sidebar" class="grid__item one-third lap-one-whole palm-one-whole">
<div class="grid">
<section class="aside-module grid__item one-whole lap-one-half">
<h1 class="title delta">About Home Assistant</h1>
<ul class="divided">
<li>
Home Assistant is an open-source home automation platform running on Python 3. Track and control all devices at home and automate control.
</li>
<li><a href='/getting-started/'>Get started with Home Assistant</a></li>
<li><a href='/demo/'>Try the online demo</a></li>
<li><a class="twitter-follow-button" href="https://twitter.com/Home_Assistant">Follow Home Assistant on Twitter</a></li>
<li><div class="fb-like" data-href="https://www.facebook.com/homeassistantio/" data-layout="standard" data-action="like" data-size="small" data-show-faces="true" data-share="false"></div></li>
</ul>
</section>
<div id="fb-root"></div>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.async=true;js.src='//platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<script>(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(d.getElementById(id)){return;}js=d.createElement(s);js.id=id;js.async=true;js.src="//connect.facebook.net/en_US/all.js#appId=338291289691179&xfbml=1";fjs.parentNode.insertBefore(js,fjs);}(document,'script','facebook-jssdk'));</script>
<section class="sharing aside-module grid__item one-whole lap-one-half">
<h1 class="title delta">Share this post</h1>
<a href="//twitter.com/share"
class="twitter-share-button"
data-via="home_assistant"
data-related="home_assistant"
data-url="https://home-assistant.io/blog/2016/02/09/Smarter-Smart-Things-with-MQTT-and-Home-Assistant/"
data-counturl="https://home-assistant.io/blog/2016/02/09/Smarter-Smart-Things-with-MQTT-and-Home-Assistant/" >Tweet</a>
<div class="fb-share-button" style='top: -6px;'
data-href="https://home-assistant.io/blog/2016/02/09/Smarter-Smart-Things-with-MQTT-and-Home-Assistant/"
data-layout="button_count">
</div>
<div class="g-plusone" data-size="standard"></div>
</section>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<section id="recent-posts" class="aside-module grid__item one-whole lap-one-half">
<h1 class="title delta">Recent Posts</h1>
<ul class="divided">
<li class="post">
<a href="/blog/2016/12/03/remote-websockets-sonarr/">0.34: New Remote component, Websockets, Sonarr, GPSLogger</a>
</li>
<li class="post">
<a href="/blog/2016/11/20/calendar-wink-thermostats-cisco-ios/">0.33: New Calendar component, Wink thermostats and Cisco IOS</a>
</li>
<li class="post">
<a href="/blog/2016/11/05/hacktoberfest-influxdb-weather/">0.32: Hacktoberfest, InfluxDB sensor, Error reporting, and Weather</a>
</li>
<li class="post">
<a href="/blog/2016/10/25/explaining-the-updater/">Explaining the Updater</a>
</li>
<li class="post">
<a href="/blog/2016/10/22/flash-briefing-updater-hacktoberfest/">0.31: Reading you the news, some serious business, spooky hackery and a breaking Z-Wave change</a>
</li>
</ul>
</section>
</div>
</aside>
</div>
</div>
<footer>
<div class="grid-wrapper">
<div class="grid">
<div class="grid__item">
<div class="copyright">
<a rel="me" href='https://twitter.com/home_assistant'><i class="icon-twitter"></i></a>
<a rel="me" href='https://facebook.com/homeassistantio'><i class="icon-facebook"></i></a>
<a rel="me" href='https://plus.google.com/110560654828510104551'><i class="icon-google-plus"></i></a>
<a rel="me" href='https://github.com/home-assistant/home-assistant'><i class="icon-github"></i></a>
<div class="credit">
Contact us at <a href='mailto:hello@home-assistant.io'>hello@home-assistant.io</a>.<br>
Website powered by <a href='http://jekyllrb.com/'>Jekyll</a> and the <a href='https://github.com/coogie/oscailte'>Oscalite theme</a>.<br />
Hosted by <a href='https://pages.github.com/'>GitHub</a> and served by <a href='https://cloudflare.com'>CloudFlare</a>.
</div>
</div>
</div>
</div>
</div>
</footer>
<script>
var _gaq=[['_setAccount','UA-57927901-1'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
<script>
var disqus_shortname = 'home-assistant';
// var disqus_developer = 1;
var disqus_identifier = 'https://home-assistant.io/blog/2016/02/09/Smarter-Smart-Things-with-MQTT-and-Home-Assistant/';
var disqus_url = 'https://home-assistant.io/blog/2016/02/09/Smarter-Smart-Things-with-MQTT-and-Home-Assistant/';
var disqus_script = 'embed.js';
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/' + disqus_script;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
</script>
</body>
</html>