Introducing Birdhouse: a .NET API for Nest Thermostat and Nest Protect

A month or so ago our heater broke down and had to be completely replaced. Whilst the old thermostat we had was still working I thought it would be fun to try out one of the Nest Thermostats that I've heard people raving about. Unfortunately Nest doesn't retail in Australia but I managed to get one shipped from Amazon.

Once installed it was a breeze to setup. It really is a smart device, we haven't manually set any schedule, we just adjusted the temperature for what we liked and after about a week it was doing it by itself. You can even adjust the thermostat remotely via your smart phone or on a web-browser. Whilst the web app is fine (and mobile friendly) I wanted to have a native experience, and therein lies the problem. Nest only ships a client for Android and iOS, no Windows Phone support, which is the platform that I prefer to use.

Fortunately Nest has a developer portal where they document a REST-based API for reading and writing data from user's Nest accounts. So for the past month or so I've been steadily building up a .NET portable class library which covers the majority of functionality exposed by the API. Using the library is pretty simple. Using NuGet, pull down the latest version of the client.

Install-Package Birdhouse  

This will pull down and install the package, then all you need to do is new up the client and start interacting with the thermostats.

var client = new NestClient(accessToken);  
var thermostat = await client.GetThermostat(thermostatID);  
await thermostat.UpdateTargetTemperatureAsync(21, TemperatureScale.Celsius);  

Whilst there are already some unofficial Nest clients out there for Windows Phone, I wanted a library that I could reuse across a few projects. If you are interested in trying out the library you can find out more on the GitHub page.