Fixed boundary issues

This commit is contained in:
Arne 2019-09-21 14:47:41 +02:00
parent 0ac882414a
commit 7594843bb3

View File

@ -100,7 +100,7 @@ NeatoVacuumRobotAccessory.prototype = {
.setCharacteristic(Characteristic.Manufacturer, "Neato Robotics") .setCharacteristic(Characteristic.Manufacturer, "Neato Robotics")
.setCharacteristic(Characteristic.Model, "Coming soon") .setCharacteristic(Characteristic.Model, "Coming soon")
.setCharacteristic(Characteristic.SerialNumber, this.robot._serial); .setCharacteristic(Characteristic.SerialNumber, this.robot._serial);
if (!this.boundary) if (typeof this.boundary === "undefined")
{ {
this.informationService this.informationService
.setCharacteristic(Characteristic.Name, this.robot.name) .setCharacteristic(Characteristic.Name, this.robot.name)
@ -116,10 +116,16 @@ NeatoVacuumRobotAccessory.prototype = {
this.services = [this.informationService, this.vacuumRobotBatteryService]; this.services = [this.informationService, this.vacuumRobotBatteryService];
if (!this.boundary) if (typeof this.boundary === "undefined")
{ {
this.vacuumRobotCleanService.getCharacteristic(Characteristic.On).on('set', this.setClean.bind(this)); this.vacuumRobotCleanService.getCharacteristic(Characteristic.On).on('set', (on, serviceCallback) =>
this.vacuumRobotCleanService.getCharacteristic(Characteristic.On).on('get', this.getClean.bind(this)); {
this.setClean(on, serviceCallback, this.boundary)
});
this.vacuumRobotCleanService.getCharacteristic(Characteristic.On).on('get', (serviceCallback) =>
{
this.getClean(serviceCallback, this.boundary);
});
this.vacuumRobotGoToDockService.getCharacteristic(Characteristic.On).on('set', this.setGoToDock.bind(this)); this.vacuumRobotGoToDockService.getCharacteristic(Characteristic.On).on('set', this.setGoToDock.bind(this));
this.vacuumRobotGoToDockService.getCharacteristic(Characteristic.On).on('get', this.getGoToDock.bind(this)); this.vacuumRobotGoToDockService.getCharacteristic(Characteristic.On).on('get', this.getGoToDock.bind(this));
@ -153,8 +159,7 @@ NeatoVacuumRobotAccessory.prototype = {
if (this.hiddenServices.indexOf('schedule') === -1) if (this.hiddenServices.indexOf('schedule') === -1)
this.services.push(this.vacuumRobotScheduleService); this.services.push(this.vacuumRobotScheduleService);
} }
else
if (this.boundary)
{ {
this.vacuumRobotCleanBoundaryService.getCharacteristic(Characteristic.On).on('set', (on, serviceCallback) => this.vacuumRobotCleanBoundaryService.getCharacteristic(Characteristic.On).on('set', (on, serviceCallback) =>
{ {
@ -185,7 +190,7 @@ NeatoVacuumRobotAccessory.prototype = {
cleaning = this.robot.canPause && (this.robot.cleaningBoundaryId === boundary.id) cleaning = this.robot.canPause && (this.robot.cleaningBoundaryId === boundary.id)
} }
debug(this.name + ": Is cleaning: " + cleaning); debug(this.name + ": Cleaning is " + (cleaning ? 'ON' : 'OFF'));
callback(false, cleaning); callback(false, cleaning);
}); });
}, },
@ -197,6 +202,8 @@ NeatoVacuumRobotAccessory.prototype = {
// Start // Start
if (on) if (on)
{ {
debug(typeof boundary);
debug(boundary);
// No room given or same room // No room given or same room
if (typeof boundary === 'undefined' || this.robot.cleaningBoundaryId === boundary.id) if (typeof boundary === 'undefined' || this.robot.cleaningBoundaryId === boundary.id)
{ {
@ -225,7 +232,8 @@ NeatoVacuumRobotAccessory.prototype = {
if (this.robot.canPause || this.robot.canResume) if (this.robot.canPause || this.robot.canResume)
{ {
debug(this.name + ": Returning to dock to start cleaning of new room"); debug(this.name + ": Returning to dock to start cleaning of new room");
this.setGoToDock(true, (error, result) => { this.setGoToDock(true, (error, result) =>
{
this.nextRoom = boundary; this.nextRoom = boundary;
setTimeout(() => setTimeout(() =>
@ -274,8 +282,8 @@ NeatoVacuumRobotAccessory.prototype = {
let eco = this.vacuumRobotEcoService.getCharacteristic(Characteristic.On).value; let eco = this.vacuumRobotEcoService.getCharacteristic(Characteristic.On).value;
let extraCare = this.vacuumRobotExtraCareService.getCharacteristic(Characteristic.On).value; let extraCare = this.vacuumRobotExtraCareService.getCharacteristic(Characteristic.On).value;
let nogoLines = this.vacuumRobotNoGoLinesService.getCharacteristic(Characteristic.On).value; let nogoLines = this.vacuumRobotNoGoLinesService.getCharacteristic(Characteristic.On).value;
let room = typeof boundary === 'undefined' ? '' : boundary.name; let room = (typeof boundary === 'undefined') ? '' : boundary.name;
debug(that.name + ": Start cleaning (" + room + " eco: " + eco + ", extraCare: " + extraCare + ", nogoLines: " + nogoLines + ")"); debug(this.name + ": Start cleaning (" + room + " eco: " + eco + ", extraCare: " + extraCare + ", nogoLines: " + nogoLines + ")");
// Normal cleaning // Normal cleaning
if (typeof boundary === 'undefined') if (typeof boundary === 'undefined')
@ -533,7 +541,8 @@ NeatoVacuumRobotAccessory.prototype = {
// Robot has a next room to clean in queue // Robot has a next room to clean in queue
if (this.nextRoom !== null && this.robot.isDocked) if (this.nextRoom !== null && this.robot.isDocked)
{ {
this.clean((error, result) => { this.clean((error, result) =>
{
this.nextRoom = null; this.nextRoom = null;
}, this.nextRoom); }, this.nextRoom);
} }
@ -554,7 +563,7 @@ NeatoVacuumRobotAccessory.prototype = {
// robot is not cleaning, no specific refresh interval is set -> stop updating // robot is not cleaning, no specific refresh interval is set -> stop updating
else else
{ {
debug(this.name + ": Disabled background updates"); debug(this.name + ": Disabled Background Updates");
} }
}); });
}, },