5 Commits

3 changed files with 46 additions and 17 deletions

View File

@@ -90,4 +90,14 @@
## 0.6.1
* Fixed homebridge startup failed when robot does not support zone cleaning
* Fixed homebridge startup failed when robot does not support zone cleaning
## 0.6.2
* Fixed homebridge startup failed when robot does not support mapping
## 0.6.3
* Fixed homebridge crash when robot has a map without zones
* Fixed homebridge crash when homebridge has no internet connection or the neato servers are offline
* Fixed homebridge crash when 2 zones have the same name

View File

@@ -37,19 +37,25 @@ function NeatoVacuumRobotPlatform(log, config) {
NeatoVacuumRobotPlatform.prototype = {
accessories: function (callback) {
let accessories = [];
let that = this;
that.boundaryNames = [];
this.getRobots(function () {
for (let i = 0; i < that.robots.length; i++) {
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);
accessories.push(robotAccessory);
that.robots[i].maps.forEach((map) => {
map.boundaries.forEach((boundary) => {
if (boundary.type === "polygon") {
accessories.push(new NeatoVacuumRobotAccessory(that.robots[i], that, boundary))
}
})
if (that.robots) {
that.robots.forEach((robot, i) => {
that.log("Found robot #" + (i + 1) + " named \"" + robot.name + "\" with serial \"" + robot._serial + "\"");
let robotAccessory = new NeatoVacuumRobotAccessory(robot, that);
accessories.push(robotAccessory);
if (robot.maps) {
robot.maps.forEach((map) => {
if (map.boundaries) {
map.boundaries.forEach((boundary) => {
if (boundary.type === "polygon") {
accessories.push(new NeatoVacuumRobotAccessory(robot, that, boundary))
}
})
}
})
}
})
}
callback(accessories);
@@ -63,7 +69,7 @@ NeatoVacuumRobotPlatform.prototype = {
client.authorize(this.email, this.password, false, (error) => {
if (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();
} else {
client.getRobots((error, robots) => {
@@ -129,6 +135,19 @@ function NeatoVacuumRobotAccessory(robot, platform, boundary) {
if (!this.boundary) {
this.name = robot.name;
} else {
// if boundary name already exists
if (platform.boundaryNames.includes(this.boundary.name)) {
let lastChar = this.boundary.name.slice(-1);
// boundary name already contains a count number
if (!isNaN(lastChar)) {
// Increment existing count number
this.boundary.name = this.boundary.name.slice(0, -1) + (parseInt(lastChar) + 1);
} else {
// Add a new count number
this.boundary.name = this.boundary.name + " 2";
}
}
platform.boundaryNames.push(this.boundary.name);
this.name = this.robot.name + ' - ' + this.boundary.name;
}
this.lastUpdate = null;
@@ -304,7 +323,7 @@ NeatoVacuumRobotAccessory.prototype = {
nogoLines,
function (error, result) {
if (error) {
that.log.error(error + ": " + result);
that.log.error("Cannot start cleaning. " + error + ": " + result);
callback(true);
} else {
callback();
@@ -312,7 +331,7 @@ NeatoVacuumRobotAccessory.prototype = {
});
}
} else {
debug(that.name + ": Cant start, maybe already cleaning");
debug(that.name + ": Cannot start, maybe already cleaning");
callback();
}
} else {
@@ -460,7 +479,7 @@ NeatoVacuumRobotAccessory.prototype = {
debug(this.name + ": Updating robot state");
this.robot.getState(function (error, result) {
if (error) {
that.log.error(error + ": " + result);
that.log.error("Cannot update robot. Check if robot is online. " + error);
}
that.lastUpdate = new Date();
callback();

View File

@@ -1,6 +1,6 @@
{
"name": "homebridge-neato",
"version": "0.6.1",
"version": "0.6.3",
"description": "A Neato vacuum robot plugin for homebridge.",
"license": "MIT",
"keywords": [