Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
0338580c0a | ||
|
54f303394e | ||
|
c43a666378 | ||
|
20c54a02e8 | ||
|
1436e4b342 |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -90,4 +90,14 @@
|
|||||||
|
|
||||||
## 0.6.1
|
## 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
|
49
index.js
49
index.js
@@ -37,19 +37,25 @@ function NeatoVacuumRobotPlatform(log, config) {
|
|||||||
NeatoVacuumRobotPlatform.prototype = {
|
NeatoVacuumRobotPlatform.prototype = {
|
||||||
accessories: function (callback) {
|
accessories: function (callback) {
|
||||||
let accessories = [];
|
let accessories = [];
|
||||||
|
|
||||||
let that = this;
|
let that = this;
|
||||||
|
that.boundaryNames = [];
|
||||||
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);
|
||||||
that.robots[i].maps.forEach((map) => {
|
accessories.push(robotAccessory);
|
||||||
map.boundaries.forEach((boundary) => {
|
if (robot.maps) {
|
||||||
if (boundary.type === "polygon") {
|
robot.maps.forEach((map) => {
|
||||||
accessories.push(new NeatoVacuumRobotAccessory(that.robots[i], that, boundary))
|
if (map.boundaries) {
|
||||||
}
|
map.boundaries.forEach((boundary) => {
|
||||||
})
|
if (boundary.type === "polygon") {
|
||||||
|
accessories.push(new NeatoVacuumRobotAccessory(robot, that, boundary))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
callback(accessories);
|
callback(accessories);
|
||||||
@@ -63,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) => {
|
||||||
@@ -129,6 +135,19 @@ function NeatoVacuumRobotAccessory(robot, platform, boundary) {
|
|||||||
if (!this.boundary) {
|
if (!this.boundary) {
|
||||||
this.name = robot.name;
|
this.name = robot.name;
|
||||||
} else {
|
} 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.name = this.robot.name + ' - ' + this.boundary.name;
|
||||||
}
|
}
|
||||||
this.lastUpdate = null;
|
this.lastUpdate = null;
|
||||||
@@ -304,7 +323,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();
|
||||||
@@ -312,7 +331,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 {
|
||||||
@@ -460,7 +479,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();
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "homebridge-neato",
|
"name": "homebridge-neato",
|
||||||
"version": "0.6.1",
|
"version": "0.6.3",
|
||||||
"description": "A Neato vacuum robot plugin for homebridge.",
|
"description": "A Neato vacuum robot plugin for homebridge.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
Reference in New Issue
Block a user