Now I wonder how can I get the plug to turn on at given times of the day, and then of at other times. I want this plug to turn on a lamp at 6 am and again at 4pm, and turn it of at 9am and 1am. I tried to make a cron job using this thread: viewtopic.php?f=3419&t=20601, but it the commands never fires.
Here's the script I use:
Code: Select all
executeFile("/userModules/cron.js");
var Crontab = new Cron(); //instatiates the Cron module
//simple example of turn on a wallPlug at specific time automatically
//runs every day, at 12h01m00sec
Crontab.add( new Cron.Job( "0 01 12 * * *", function () {
//get status of the switch. Change N and I, according to your actual config
var status = zway.devices[5].instances[0].SwitchBinary.data.level.value;
//if the swich is off, turn it on
if(status==false){
zway.devices[5].instances[0].SwitchBinary.Set(255);
}
}));
//runs every day, at 12h00m00sec
Crontab.add( new Cron.Job( "0 00 12 * * *", function () {
//get status of the switch. Change N and I, according to your actual config
var status = zway.devices[5].instances[0].SwitchBinary.data.level.value;
//if the swich is on, turn it off
if(status==true){
zway.devices[5].instances[0].SwitchBinary.Set(0);
}
}));
Crontab.start();
Thanks!