This is my first script.. when I tell it to run the script, it seems to run, I get my restart message, but I never seem to get zone events. Do I need to initialize something?
var boilerOnD = new Date();
helper.logToExternalFile('BoilerStats.csv',"Boiler Status Restart " + boilerOnD.toLocaleString());
function sleep(delay) {
var start = new Date().getTime();
while (new Date().getTime() < start + delay);
}
function onZoneNotReady (zone) {
if (zone.number == 5) { // Driveway Sensor
helper.sendNotification(controller, zone.bestDescription + 'Driveway Tripped' );
}
if (zone.number == 6) { // Boiler Demand
var boilerStatus = "boiler on,";
boilerOnD = new Date();
boilerStatus += boilerOnD.toLocaleTimeString() + ",";
var thermostats = controller.thermostats;
for (i in thermostats) {
if( i == 1){
boilerStatus += thermostats.outdoorTemperatureDescription + ",";
}
boilerStatus += thermostats.statusDescription + ",";
boilerStatus += thermostats.temperatureDescription + ",";
}
helper.logToExternalFile('BoilerStats.cvs',boilerStatus);
}
}
function onZoneReady (zone) {
if (zone.number == 6) { // Boiler Demand
var boilerStatus = "boiler off,";
var boilerOffD = new Date();
var duration = (boilerOffD - boilerOnD)/60000;
boilerStatus += boilerOffD.toLocaleTimeString() + ",";
var thermostats = controller.thermostats;
for (i in thermostats) {
if( i == 1){
boilerStatus += thermostats.outdoorTemperatureDescription + ",";
}
boilerStatus += thermostats.statusDescription + ",";
boilerStatus += thermostats.temperatureDescription + ",";
boilerStatus += duration.toString() + ",";
}
helper.logToExternalFile('BoilerStats.csv',boilerStatus);
}
}
var boilerOnD = new Date();
helper.logToExternalFile('BoilerStats.csv',"Boiler Status Restart " + boilerOnD.toLocaleString());
function sleep(delay) {
var start = new Date().getTime();
while (new Date().getTime() < start + delay);
}
function onZoneNotReady (zone) {
if (zone.number == 5) { // Driveway Sensor
helper.sendNotification(controller, zone.bestDescription + 'Driveway Tripped' );
}
if (zone.number == 6) { // Boiler Demand
var boilerStatus = "boiler on,";
boilerOnD = new Date();
boilerStatus += boilerOnD.toLocaleTimeString() + ",";
var thermostats = controller.thermostats;
for (i in thermostats) {
if( i == 1){
boilerStatus += thermostats.outdoorTemperatureDescription + ",";
}
boilerStatus += thermostats.statusDescription + ",";
boilerStatus += thermostats.temperatureDescription + ",";
}
helper.logToExternalFile('BoilerStats.cvs',boilerStatus);
}
}
function onZoneReady (zone) {
if (zone.number == 6) { // Boiler Demand
var boilerStatus = "boiler off,";
var boilerOffD = new Date();
var duration = (boilerOffD - boilerOnD)/60000;
boilerStatus += boilerOffD.toLocaleTimeString() + ",";
var thermostats = controller.thermostats;
for (i in thermostats) {
if( i == 1){
boilerStatus += thermostats.outdoorTemperatureDescription + ",";
}
boilerStatus += thermostats.statusDescription + ",";
boilerStatus += thermostats.temperatureDescription + ",";
boilerStatus += duration.toString() + ",";
}
helper.logToExternalFile('BoilerStats.csv',boilerStatus);
}
}