Oops, made a rookie mistake. Make sure I'm using local variables instead of global variables.

This commit is contained in:
Chloe Stars
2015-07-17 01:08:50 -07:00
parent 91602e4f99
commit c4f9e81828
+13 -13
View File
@@ -25,12 +25,12 @@ NestPlatform.prototype = {
nest.fetchStatus(function (data) { nest.fetchStatus(function (data) {
for (var deviceId in data.device) { for (var deviceId in data.device) {
if (data.device.hasOwnProperty(deviceId)) { if (data.device.hasOwnProperty(deviceId)) {
device = data.device[deviceId]; var device = data.device[deviceId];
// it's a thermostat, adjust this to detect other accessories // it's a thermostat, adjust this to detect other accessories
if (data.shared[deviceId].hasOwnProperty('current_temperature')) if (data.shared[deviceId].hasOwnProperty('current_temperature'))
{ {
name = data.shared[deviceId].name var name = data.shared[deviceId].name
accessory = new NestThermostatAccessory(that.log, name, device, deviceId); var accessory = new NestThermostatAccessory(that.log, name, device, deviceId);
foundAccessories.push(accessory); foundAccessories.push(accessory);
} }
} }
@@ -58,9 +58,9 @@ NestThermostatAccessory.prototype = {
this.log("Checking current heating cooling for: " + this.name); this.log("Checking current heating cooling for: " + this.name);
nest.fetchStatus(function (data) { nest.fetchStatus(function (data) {
device = data.device[that.deviceId]; var device = data.device[that.deviceId];
currentHeatingCooling = 0; var currentHeatingCooling = 0;
switch(device.current_schedule_mode) { switch(device.current_schedule_mode) {
case "OFF": case "OFF":
targetHeatingCooling = 0; targetHeatingCooling = 0;
@@ -90,9 +90,9 @@ NestThermostatAccessory.prototype = {
this.log("Checking target heating cooling for: " + this.name); this.log("Checking target heating cooling for: " + this.name);
nest.fetchStatus(function (data) { nest.fetchStatus(function (data) {
device = data.device[that.deviceId]; var device = data.device[that.deviceId];
targetHeatingCooling = 0; var targetHeatingCooling = 0;
switch(device.target_temperature_type) { switch(device.target_temperature_type) {
case "off": case "off":
targetHeatingCooling = 0; targetHeatingCooling = 0;
@@ -119,7 +119,7 @@ NestThermostatAccessory.prototype = {
var that = this; var that = this;
nest.fetchStatus(function (data) { nest.fetchStatus(function (data) {
device = data.shared[that.deviceId]; var device = data.shared[that.deviceId];
that.log("Current temperature for " + this.name + " is: " + device.current_temperature); that.log("Current temperature for " + this.name + " is: " + device.current_temperature);
callback(device.current_temperature); callback(device.current_temperature);
}); });
@@ -132,7 +132,7 @@ NestThermostatAccessory.prototype = {
var that = this; var that = this;
nest.fetchStatus(function (data) { nest.fetchStatus(function (data) {
device = data.shared[that.deviceId]; var device = data.shared[that.deviceId];
that.log("Target temperature for " + this.name + " is: " + device.target_temperature); that.log("Target temperature for " + this.name + " is: " + device.target_temperature);
callback(device.target_temperature); callback(device.target_temperature);
}); });
@@ -145,8 +145,8 @@ NestThermostatAccessory.prototype = {
var that = this; var that = this;
nest.fetchStatus(function (data) { nest.fetchStatus(function (data) {
device = data.device[that.deviceId]; var device = data.device[that.deviceId];
temperatureUnits = 0; var temperatureUnits = 0;
switch(device.temperature_scale) { switch(device.temperature_scale) {
case "F": case "F":
that.log("Tempature unit for " + this.name + " is: " + "Fahrenheit"); that.log("Tempature unit for " + this.name + " is: " + "Fahrenheit");
@@ -171,7 +171,7 @@ NestThermostatAccessory.prototype = {
var that = this; var that = this;
nest.fetchStatus(function (data) { nest.fetchStatus(function (data) {
device = data.device[that.deviceId]; var device = data.device[that.deviceId];
that.log("Humidity for " + this.name + " is: " + device.current_humidity); that.log("Humidity for " + this.name + " is: " + device.current_humidity);
callback(device.current_humidity); callback(device.current_humidity);
}) })
@@ -183,7 +183,7 @@ NestThermostatAccessory.prototype = {
var that = this; var that = this;
targetTemperatureType = 'off'; var targetTemperatureType = 'off';
switch(targetHeatingCooling) { switch(targetHeatingCooling) {
case 0: case 0:
// this will crash unnofficial-node-api, it needs to be forked to accept the input // this will crash unnofficial-node-api, it needs to be forked to accept the input