Fixed homebridge crash when homebridge has no internet connection or the neato servers are offline

This commit is contained in:
Arne 2019-08-14 23:06:03 +02:00
parent 20c54a02e8
commit c43a666378

View File

@ -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 + "\"");
let robotAccessory = new NeatoVacuumRobotAccessory(robot, that);
accessories.push(robotAccessory); accessories.push(robotAccessory);
if (that.robots[i].maps) { if (robot.maps) {
that.robots[i].maps.forEach((map) => { robot.maps.forEach((map) => {
if (map.boundaries) { 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(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) => {