Improved refresh parameter

This commit is contained in:
naofireblade 2017-05-06 23:57:36 +02:00
parent 36e8496108
commit 8cb6ecf8a5

View File

@ -27,17 +27,12 @@ function NeatoVacuumRobot(log, config) {
this.email = config['email']; this.email = config['email'];
this.password = config['password']; this.password = config['password'];
// load refresh time
// default 120s // default 120s
this.refresh = ('refresh' in config ? parseInt(config['refresh']) : 120); this.refresh = ('refresh' in config ? parseInt(config['refresh']) : 120);
// must be integer and positive // must be integer and positive
if (typeof this.refresh !=='number' || (this.refresh%1)!==0 || this.refresh < 0) { this.refresh = (typeof this.refresh !=='number' || (this.refresh%1)!==0 || this.refresh < 0) ? 0 : this.refresh;
this.refresh = 0;
}
// minimum 60s // minimum 60s
if (this.refresh != 0 && this.refresh < 60) { this.refresh = (this.refresh != 0 && this.refresh < 60) ? 60 : this.refresh;
this.refresh = 60;
}
this.vacuumRobotCleanService = new Service.Switch(this.name + " Clean", "clean"); this.vacuumRobotCleanService = new Service.Switch(this.name + " Clean", "clean");
this.vacuumRobotGoToDockService = new Service.Switch(this.name + " Go to Dock", "goToDock"); this.vacuumRobotGoToDockService = new Service.Switch(this.name + " Go to Dock", "goToDock");