Blog

Netatmo Weather Station on Wot.io

March 17, 2015 / Posted By: wotio team

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.

The Integration

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!

Prerequisites

To get started, you'll need the following:

  • A Netatmo Weather Station
  • A computer, virtual machine, or cloud instance with Python 2.7 installed
  • A Wotio access token and path
  • Netatmo Credentials, Client ID, and Secret Token

To get your Netatmo Credentials, register on their developer site and create a new app (https://dev.netatmo.com/dev/createapp). Your Client Id and Client Secret will be given to you there.

The integration

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.

You can find the code here:

https://github.com/WoTio/wotnetatmo

Download it, then run:

sudo python setup.py install  
wotnetatmo <netatmo username> <netatmo password> <netatmo clientid> <netatmo clientsecret> <visit http://wot.io for your wot.io path>  

Where <UUID> 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.

And that's it! Your wemo devices are now integrated into Wotio. The trick here is in the wotwrapper library. What it does is it takes the functions in a python class (in this case the Netatmo class) and wraps them into Wot-style JSON commands. In this case the only function available is get_state(), which is used to push data onto the Wotio bus.

For detailed usage, see the code and documentation at WoTio/wotnetatmo on Github.

The Wot side

Now that we've got our station wrapped, let's check out it's data stream on Wot.

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 progrium/wssh. 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:

wssh <visit http://wot.io for your wot.io path>  

And you should see the data stream coming from the Netatmo Weather Station, similar to the one below:

[{"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}]

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.

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!

Learn More

If you'd like to see a sample of the power you can get out of Wotio, visit the wot.io website and we'll call you to schedule a meeting.