Fixed homebridge crash when robot has a map without zones

This commit is contained in:
Arne 2019-08-14 22:48:23 +02:00
parent 1436e4b342
commit 20c54a02e8

View File

@ -44,14 +44,15 @@ NeatoVacuumRobotPlatform.prototype = {
that.log("Found robot #" + (i + 1) + " named \"" + that.robots[i].name + "\" with serial \"" + that.robots[i]._serial + "\""); that.log("Found robot #" + (i + 1) + " named \"" + that.robots[i].name + "\" with serial \"" + that.robots[i]._serial + "\"");
let robotAccessory = new NeatoVacuumRobotAccessory(that.robots[i], that); let robotAccessory = new NeatoVacuumRobotAccessory(that.robots[i], that);
accessories.push(robotAccessory); accessories.push(robotAccessory);
if (that.robots[i].maps && that.robots[i].maps.length > 0) if (that.robots[i].maps) {
{
that.robots[i].maps.forEach((map) => { that.robots[i].maps.forEach((map) => {
if (map.boundaries) {
map.boundaries.forEach((boundary) => { map.boundaries.forEach((boundary) => {
if (boundary.type === "polygon") { if (boundary.type === "polygon") {
accessories.push(new NeatoVacuumRobotAccessory(that.robots[i], that, boundary)) accessories.push(new NeatoVacuumRobotAccessory(that.robots[i], that, boundary))
} }
}) })
}
}) })
} }
} }
@ -307,7 +308,7 @@ NeatoVacuumRobotAccessory.prototype = {
nogoLines, nogoLines,
function (error, result) { function (error, result) {
if (error) { if (error) {
that.log.error(error + ": " + result); that.log.error("Cannot start cleaning. " + error + ": " + result);
callback(true); callback(true);
} else { } else {
callback(); callback();
@ -315,7 +316,7 @@ NeatoVacuumRobotAccessory.prototype = {
}); });
} }
} else { } else {
debug(that.name + ": Cant start, maybe already cleaning"); debug(that.name + ": Cannot start, maybe already cleaning");
callback(); callback();
} }
} else { } else {
@ -463,7 +464,7 @@ NeatoVacuumRobotAccessory.prototype = {
debug(this.name + ": Updating robot state"); debug(this.name + ": Updating robot state");
this.robot.getState(function (error, result) { this.robot.getState(function (error, result) {
if (error) { if (error) {
that.log.error(error + ": " + result); that.log.error("Cannot update robot. Check if robot is online. " + error);
} }
that.lastUpdate = new Date(); that.lastUpdate = new Date();
callback(); callback();