<p>Here in New York, we get very little control over our apartment's environment. Our buildings have central heating, window A/C units are the norm, and depending on how high your building goes your windows might not even open. This makes a perfect environment to use a device like the Netatmo weather station. It reports on the 'vital stats' of your environment, both indoors and outdoors (temperature, atmospheric pressure, CO2 levels, and even noise levels) so you can get a good idea of what your environment is like. But better yet, with a system like Wotio you can actually put that data to use, and have your A/Cs, windows, and heaters act on that data to create a more comfortable environment. In this post we'll get our NWS connected to Wotio, and in a future one we'll use some of Wot's partner services to automate our A/C with it.</p>
<h3 id="theintegration">The Integration</h3>
<p>One of the cool parts of this integration is that, unlike some of the others, the Device Management Platform for the NWS is cloud-based. This means that this integration can be run from anywhere without being limited to your local network. So spin up a cloud instance and try it!</p>
<h3 id="prerequisites">Prerequisites</h3>
<p>To get started, you'll need the following:</p>
<ul>
<li>A Netatmo Weather Station</li>
<li>A computer, virtual machine, or cloud instance with Python 2.7 installed</li>
<li>A Wotio access token and path</li>
<li>Netatmo Credentials, Client ID, and Secret Token</li>
</ul>
<p>To get your Netatmo Credentials, register on their developer site and create a new app (<a href="https://dev.netatmo.com/dev/createapp">https://dev.netatmo.com/dev/createapp</a>). Your Client Id and Client Secret will be given to you there.</p>
<h3 id="theintegration">The integration</h3>
<p>For this integration, we'll be using Python. Even if you don't know it it's fairly easy lanugage to read and understand what's going on.</p>
<p>You can find the code here:</p>
<p><a href="https://github.com/WoTio/wotnetatmo">https://github.com/WoTio/wotnetatmo</a></p>
<p>Download it, then run:</p>
<pre><code>sudo python setup.py install
wotnetatmo <netatmo username> <netatmo password> <netatmo clientid> <netatmo clientsecret> <visit http://wot.io for your wot.io path>
</code></pre>
<p>Where <code><UUID></code> is a random string you've generated to identify your application. If you're doing multiple integrations and want them to communicate, this should be kept as the same value.</p>
<p>And that's it! Your wemo devices are now integrated into Wotio. The trick here is in the <code>wotwrapper</code> library. What it does is it takes the functions in a python class (in this case the <code>Netatmo</code> class) and wraps them into Wot-style JSON commands. In this case the only function available is <code>get_state()</code>, which is used to push data onto the Wotio bus.</p>
<p>For detailed usage, see the code and documentation at <a href="https://github.com/WoTio/wotnetatmo">WoTio/wotnetatmo</a> on Github.</p>
<h3 id="thewotside">The Wot side</h3>
<p>Now that we've got our station wrapped, let's check out it's data stream on Wot.</p>
<p>We can connect to Wotio using several different protocols, but for our purposes we're going to use websockets. Why? Because we can use any number of mechanisms to view the data streams we're generating in real-time. If you don't have a websocket shell installed, you can try <a href="https://github.com/progrium/wssh">progrium/wssh</a>. It's also based on Python 2.7, so if you've gotten this far in the integration it should work for you perfectly fine. So let's use it to open a websocket connection to our data stream on wotio:</p>
<pre><code>wssh <visit http://wot.io for your wot.io path>
</code></pre>
<p>And you should see the data stream coming from the Netatmo Weather Station, similar to the one below:</p>
<pre><code>[{"Noise": 38, "Temperature": 22.2, "When": 1426618048, "Humidity": 42, "Pressure": 1002.6, "CO2": 1058, "AbsolutePressure": 1001.7, "date_max_temp": 1426595993, "min_temp": 21.7, "date_min_temp": 1426578048, "wifi_status": 60, "max_temp": 23.5}, {"date_min_temp": 1426582660, "rf_status": 44, "Temperature": 15, "date_max_temp": 1426614084, "min_temp": 10.3, "battery_vp": 5344, "max_temp": 16.5, "When": 1426618032, "Humidity": 41}]
</code></pre>
<p>Notice how this data is now being pushed and routed within Wotio automatically? That's what gives Wot it's power. There are lots of pre-integrated services that can act on this data. You can even integrate another device (just as easily, mind you) and Wotio gives you the power to link them together so that they can communicate no matter where they are in the world; all they need is an internet connection. For example, you could have a trigger set up so that if some data point here reaches a certain threshold, some other action occurs (say, the battery running out triggers a tweet, or some other device to turn off). And all of this is production-ready, with no infrastructure for you to maintain, should you want to take your devices (or services) to market.</p>
<p>And if you've got another device connected as described on the blog, you should be able to send and receive commands on it as well!</p>
<h1 id="learnmore">Learn More</h1>
<p>If you'd like to see a sample of the power you can get out of Wotio, visit the <a href="http://wot.io/about-wot-io/contact-us/">wot.io website</a> and we'll call you to schedule a meeting.</p>
Netatmo Weather Station on Wot.io
Mar 2015/ Posted By: wotio team