"use strict";
var Cylon = require("cylon");
Cylon
.robot()
.connection("nest", { adaptor: "nest", accessToken: "ACCESS_TOKEN" })
.device("thermostat", { driver: "nest-thermostat", deviceId: "DEVICE_ID" })
.on("ready", function(bot) {
bot.thermostat.on("value", function(data) {
console.log("The Thermostat at a glance --->", data);
});
every((30).seconds(), function() {
bot.thermostat.targetTemperatureC(24);
bot.thermostat.write("target_temperature_high_c", 30, function(err) {
if (err) {
console.log("Target Temp was NOT updated!");
} else {
console.log("Target Temp updated!");
}
});
});
});
Cylon.start();