Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
0338580c0a | ||
|
54f303394e | ||
|
c43a666378 | ||
|
20c54a02e8 |
@@ -94,4 +94,10 @@
|
||||
|
||||
## 0.6.2
|
||||
|
||||
* Fixed homebridge startup failed when robot does not support mapping
|
||||
* 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
|
50
index.js
50
index.js
@@ -37,23 +37,26 @@ 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);
|
||||
if (that.robots[i].maps && that.robots[i].maps.length > 0)
|
||||
{
|
||||
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);
|
||||
});
|
||||
@@ -66,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) => {
|
||||
@@ -132,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;
|
||||
@@ -307,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();
|
||||
@@ -315,7 +331,7 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
debug(that.name + ": Cant start, maybe already cleaning");
|
||||
debug(that.name + ": Cannot start, maybe already cleaning");
|
||||
callback();
|
||||
}
|
||||
} else {
|
||||
@@ -463,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();
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "homebridge-neato",
|
||||
"version": "0.6.2",
|
||||
"version": "0.6.3",
|
||||
"description": "A Neato vacuum robot plugin for homebridge.",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
Reference in New Issue
Block a user