We hope you love your new Nest.- Tony Faddell

The other script I want to build is to get a few more temperature gauges so that if one part of the house (office, bedroom) is more than five degrees different from the others it I can just kick on the fan-mode to circulate the air. Awesome, eh? Yeah!
checkWindowState.php:
$forecast = new ForecastIO($api_key);
$nest = new Nest();
$windowStatefile = getenv("HOME") . "/Dropbox/scripts/nest/windowstate.txt";
$windowStateString = rtrim(file_get_contents($windowStatefile));
$windowState = "closed";
if($windowStateString == "open") {
$windowState = "open";
}
// Get the device information:
$mode = $nest->getDeviceInfo()->current_state->mode;
$insideTemp = $nest->getDeviceInfo()->current_state->temperature;
// Get the NEST reported tempurature
$locationArray = $nest->getUserLocations();
$nestOutsideTemp = $locationArray[0]->outside_temperature;
$outsideTemp = nestOutsideTemp;
$condition = $forecast->getCurrentConditions($latitude, $longitude);
$forecastIoOutsideTemp = $condition->getTemperature();
$outsideTemp = $forecastIoOutsideTemp;
if($mode == "cool"
&& $windowState == "closed"
&& $outsideTemp < $insideTemp ) {
$windowState = "open";
exec("/usr/local/bin/growlnotify -s --image ~/Dropbox/scripts/nest/nest.icns -n \"Nest\" -p Moderate -m \"It's cooling off, open your windows.\"");
} elseif ($mode == "cool"
&& $windowState == "open"
&& $outsideTemp > $insideTemp ) {
$windowState = "closed";
exec("/usr/local/bin/growlnotify -s --image ~/Dropbox/scripts/nest/nest.icns -n \"Nest\" -p Moderate -m \"It's warming up, close your windows.\"");
}
file_put_contents($windowStatefile, $windowState);