Graphing Nest vs the Outside

Getting acquainted with Google's new Nest API

Graphing Nest vs the Outside

Google killed Works With Nest this year, which I found out after moving to a new apartment and having to setup a new thermostat. I had previously written a Nagios plugin which compared the indoor temp/humidity vs the outdoor temp/humidity on OpenWeather, and was frustrated to find that the new device sandbox wouldn't be available to individuals until near the end of the year. Well, it's finally out! It's completely unfriendly to hobbyists, but it's out!

Here's the project: https://github.com/blakehartshorn/go-nest-temp-monitor

This time, I wrote it as a stand alone daemon which writes to InfluxDB directly. I used 3 different weather sites with configurable intervals. The whole thing is written in Go because Influx is written in Go and I like the http client.

Observations

InfluxDB

I can't believe I ever used Graphite. It was easier to setup in Icinga which was a huge monitoring project I took on at the time, but since migrating that project and my personal ones to InfluxDB, I am now spoiled by the ease of use, speed, and how much nicer it plays with Grafana. I have 3 different services writing to it on my home server and it is using barely any resources. At work, I have Icinga setup with over 70,000 services, and after nearly a year it's only using 66GB of data. For this project, I use the timestamps provided by the weather outlets for deduplication purposes and it's working out nicely.

Google Nest Device Access Sandbox

What a mess this is. Works With Nest just let you generate an API key and be on your merry way. This thing is a slap in the face to anyone who buys a Nest to actually leverage having a smart thermostat. I'm not trying to generate an application for the public, I'm trying to get my home server to log thermostat data. Regardless, Google makes you setup a redirect URI for oauth, configure a sign in dashboard for the cloud, and other various things which assume you're actually writing a web app for mass consumption. If you're just writing a happy little daemon, you're going to be curling a bunch of stuff to eventually get the refresh token. Also, it costs $5.

Read up on this unnecessary headache here: https://developers.google.com/nest/device-access/registration

If you choose to use my project, the config winds up needing the client id, client secret and refresh token. It requests a new access token every 45 minutes. If you ever sign out, happy curling (again).

There's a lot of data in the API output, but it doesn't feature HOME/AWAY like Works with Nest did. You can get a peak into the API here: https://developers.google.com/nest/device-access/api/thermostat

National Weather Service (weather.gov)

The first of 3 weather sites I wrote integrations for. This one is only applicable to the United States. It's free and requires no API key, all you need to do is search for your city and grab the weather station identification code (in my case, KBOS). It only updates once or twice an hour, so I check it every 10 minutes and let Influx use the provided timestamp for deduplication. It occasionally returns all zeroes, so I aim to throw in a fix for that soon.

Have a look here: https://api.weather.gov/stations/KBOS/observations/latest

OpenWeather

This is the weather site I was primarily using with the old check. It's free and works great. The quirky thing with it when comparing to other weather sites is that I think the station is placed in a weird spot. It always reports hotter during the day and colder at night than the other 2 weather sites. I'm thinking it's setup in the sun and in the wind, which I suppose could give a more accurate feel. Regardless, it's what I'm currently overlaying with the Nest temperatures in Grafana.

API doc for current weather information: https://openweathermap.org/current

AccuWeather

This has been my go-to weather website for a long time. They have an API, but like Google in this case, they don't expect hobbyists to actually use it. I just picked "business to business" instead of "business to consumer" when registering my app and so far no one cares. The "free trial" for developers limits you to 50 API calls a day, or one every 30 minutes. I don't see anything telling me I can't just do 50 calls a day forever. It's $25 a month for the entry level plan where I could check as often as I want, but I don't see how that's worth it.

API doc for current weather information: https://developer.accuweather.com/accuweather-current-conditions-api/apis/get/currentconditions/v1/{locationKey}

Collected Data

Weather sites

This was fun to observe. Weather.gov is pointing to East Boston, AccuWeather and OpenWeather are both reporting the neighborhood I live in just northeast of it. I'm able to compare the temperature, humidity and pressure. All the data I'm getting is actually in Celsius, but you can get Fahrenheit right from the influx query, e.g.

select (temperature * 1.8 + 32) from weathergov where time >= now() - 1h

Nest

I'm gathering the following details from the thermostat and placing them in InfluxDB:

  • Temperature (C)
  • Humidity (%)
  • HVAC (0/1)
  • MODE (HEAT/COOL/HEATCOOL/MANUAL_ECO)
  • Heat (C)
  • Cool (C)
  • Device name
  • Parent relationship

In my Grafana setup, I've overlaid the weather with the indoor temp/humidity, also graphing in the thermostat cool/heat settings and whether or not the HVAC is running. It's fall here in Boston so I haven't needed it running lately.

Conclusion

I hate the new Google Nest Device Access program. I don't even like that it's cloud based. I'd be happy to just be able to query the thing on my local network. I don't know why IoT in general doesn't support simple local access APIs. My old Icinga solution for this was written in an afternoon with no pain.

Either way, I'm happy to have historical data for my thermostat again. Now if I can just find a way to monitor the electric and gas usage...