Fixed homebridge crash when homebridge has no internet connection or the neato servers are offline
This commit is contained in:
parent
20c54a02e8
commit
c43a666378
34
index.js
34
index.js
@ -40,21 +40,23 @@ NeatoVacuumRobotPlatform.prototype = {
|
|||||||
|
|
||||||
let that = this;
|
let that = this;
|
||||||
this.getRobots(function () {
|
this.getRobots(function () {
|
||||||
for (let i = 0; i < that.robots.length; i++) {
|
if (that.robots) {
|
||||||
that.log("Found robot #" + (i + 1) + " named \"" + that.robots[i].name + "\" with serial \"" + that.robots[i]._serial + "\"");
|
that.robots.forEach((robot, i) => {
|
||||||
let robotAccessory = new NeatoVacuumRobotAccessory(that.robots[i], that);
|
that.log("Found robot #" + (i + 1) + " named \"" + robot.name + "\" with serial \"" + robot._serial + "\"");
|
||||||
accessories.push(robotAccessory);
|
let robotAccessory = new NeatoVacuumRobotAccessory(robot, that);
|
||||||
if (that.robots[i].maps) {
|
accessories.push(robotAccessory);
|
||||||
that.robots[i].maps.forEach((map) => {
|
if (robot.maps) {
|
||||||
if (map.boundaries) {
|
robot.maps.forEach((map) => {
|
||||||
map.boundaries.forEach((boundary) => {
|
if (map.boundaries) {
|
||||||
if (boundary.type === "polygon") {
|
map.boundaries.forEach((boundary) => {
|
||||||
accessories.push(new NeatoVacuumRobotAccessory(that.robots[i], that, boundary))
|
if (boundary.type === "polygon") {
|
||||||
}
|
accessories.push(new NeatoVacuumRobotAccessory(robot, that, boundary))
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
callback(accessories);
|
callback(accessories);
|
||||||
});
|
});
|
||||||
@ -67,7 +69,7 @@ NeatoVacuumRobotPlatform.prototype = {
|
|||||||
client.authorize(this.email, this.password, false, (error) => {
|
client.authorize(this.email, this.password, false, (error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
that.log(error);
|
that.log(error);
|
||||||
that.log.error("Can't log on to neato cloud. Please check your credentials.");
|
that.log.error("Can't log on to neato cloud. Please check your internet connection and your credentials. Try again later if the neato servers have issues.");
|
||||||
callback();
|
callback();
|
||||||
} else {
|
} else {
|
||||||
client.getRobots((error, robots) => {
|
client.getRobots((error, robots) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user