Last fall I purchased and installed the Filtrete Touchscreen WiFi-Enabled Programmable Thermostat in our home after reading about it here on Scott Hanselman’s blog. It does exactly what it sounds like, plus it comes with a pretty cool iPhone app (I am sure there is an android version as well).

Now that we have it installed, it would be hard to imagine life without it. It seems really lazy (and it is) but the thought of having to actually get up and interact with a device on the wall seems like a lot work. And the real benefit is in the middle of the night, when you want to change the temperature, you do not need to actually get out of bed to do it.

The ability to change the temperature at home, while you are away is really where it shines. Forget to turn off the air conditioning in the middle of the summer, when you were planning on being out all Saturday? Maybe forgot to set it to ‘away mode’ before you left for vacation? Neither is a problem that takes over 30 seconds to solve with your phone.

The cool thing about the thermostat is not only does it have all of these features but it also hosts a JSON restful webservice that allows you to query or change the temperature/settings. Here is my C# code that talks to it. I am using the newtonsoft json framework to handle the parsing of the json method, which I pulled down from the NuGet repository.

var client = new WebClient();
client.Headers.Add("User-Agent", "Nobody");

var response = client.DownloadString(new Uri("insert-thermostat-url-here/tstat"));
dynamic resource = JObject.Parse(response);

RadioThermostatStatus status = new RadioThermostatStatus() {
  CurrentTemp = resource.temp,
  ThermostatOperationMode = resource.tmode,
  FanOperationMode = resource.fmode,
  TargetTemp_Cool = resource.t_cool,
  TargetTemp_Heat = resource.t_heat,
  HVACOperationState = resource.tstate
};

Here, in a few lines of code, I am able to determine the current conditions inside the house. I have this code running every few minutes inside of a windows service that is running on my server.

What in the world can could you do with this information? For one thing, I can send alerts to myself if things get out of control:

// If current temp is outside emergency bounds send a notification
if (status.CurrentTemp >= MAXINSIDETEMP || status.CurrentTemp <= MININSIDETEMP)
{
  string message = "EMERGENCY: HOUSE INSIDE TEMP IS AT: " + status.CurrentTemp;
  logger.Warn(message);
  notifyClient.NotifyKevin(message);
}

Here I have min and max temperatures set so that if the inside temperature is outside of a certain threshold (to the point that I should be looking into it) it sends me a notification via BoxCar notification which is sent straight to my iPhone. It is communicating with a simple WCF webservice I set up on my machine that calls the BoxCar service (more on that later).

Is there more you can do with this webservice? Yes there is, and I will be showing a few cool uses I have come up with, so stay tuned.