Fixed some issues and added more device info

This commit is contained in:
Arne 2019-09-22 16:07:35 +02:00
parent 114ff70d60
commit c6def8c0fc
3 changed files with 37 additions and 21 deletions

View File

@ -107,3 +107,5 @@
* Fixed room switches not taking eco and extraCare mode into account * Fixed room switches not taking eco and extraCare mode into account
* Fixed room switches to support pause/resume of cleaning * Fixed room switches to support pause/resume of cleaning
* Added feature that enabling another room switch, returns to robot to dock and starts cleaning the new room automatically * Added feature that enabling another room switch, returns to robot to dock and starts cleaning the new room automatically
* Improved requests for multiple rooms (TODO)
* Added model and firmware information to homekit

View File

@ -20,6 +20,7 @@ function NeatoVacuumRobotAccessory(robotObject, platform, boundary = undefined)
this.hiddenServices = platform.hiddenServices; this.hiddenServices = platform.hiddenServices;
this.robot = robotObject.device; this.robot = robotObject.device;
this.nextRoom = null; this.nextRoom = null;
this.meta = robotObject.meta;
if (typeof boundary === 'undefined') if (typeof boundary === 'undefined')
{ {
@ -51,7 +52,7 @@ function NeatoVacuumRobotAccessory(robotObject, platform, boundary = undefined)
if (typeof boundary === 'undefined') if (typeof boundary === 'undefined')
{ {
this.vacuumRobotCleanService = new Service.Switch("Clean", "clean"); this.vacuumRobotCleanService = new Service.Switch(this.name + " Clean", "clean");
this.vacuumRobotGoToDockService = new Service.Switch(this.name + " Go to Dock", "goToDock"); this.vacuumRobotGoToDockService = new Service.Switch(this.name + " Go to Dock", "goToDock");
this.vacuumRobotDockStateService = new Service.OccupancySensor(this.name + " Dock", "dockState"); this.vacuumRobotDockStateService = new Service.OccupancySensor(this.name + " Dock", "dockState");
this.vacuumRobotEcoService = new Service.Switch(this.name + " Eco Mode", "eco"); this.vacuumRobotEcoService = new Service.Switch(this.name + " Eco Mode", "eco");
@ -95,8 +96,9 @@ NeatoVacuumRobotAccessory.prototype = {
this.informationService = new Service.AccessoryInformation(); this.informationService = new Service.AccessoryInformation();
this.informationService this.informationService
.setCharacteristic(Characteristic.Manufacturer, "Neato Robotics") .setCharacteristic(Characteristic.Manufacturer, "Neato Robotics")
.setCharacteristic(Characteristic.Model, "Coming soon") .setCharacteristic(Characteristic.Model, this.meta.modelName)
.setCharacteristic(Characteristic.SerialNumber, this.robot._serial); .setCharacteristic(Characteristic.SerialNumber, this.robot._serial)
.setCharacteristic(Characteristic.FirmwareRevision, this.meta.firmware);
if (typeof this.boundary === "undefined") if (typeof this.boundary === "undefined")
{ {
this.informationService this.informationService
@ -200,15 +202,13 @@ NeatoVacuumRobotAccessory.prototype = {
// Start // Start
if (on) if (on)
{ {
debug(typeof boundary);
debug(boundary);
// No room given or same room // No room given or same room
if (typeof boundary === 'undefined' || this.robot.cleaningBoundaryId === boundary.id) if (typeof boundary === 'undefined' || this.robot.cleaningBoundaryId === boundary.id)
{ {
// Resume cleaning // Resume cleaning
if (this.robot.canResume) if (this.robot.canResume)
{ {
debug(this.name + ": Resume cleaning"); debug(this.name + ": ## Resume cleaning");
this.robot.resumeCleaning(callback); this.robot.resumeCleaning(callback);
} }
// Start cleaning // Start cleaning
@ -229,7 +229,7 @@ NeatoVacuumRobotAccessory.prototype = {
// Return to dock // Return to dock
if (this.robot.canPause || this.robot.canResume) if (this.robot.canPause || this.robot.canResume)
{ {
debug(this.name + ": Returning to dock to start cleaning of new room"); debug(this.name + ": ## Returning to dock to start cleaning of new room");
this.setGoToDock(true, (error, result) => this.setGoToDock(true, (error, result) =>
{ {
this.nextRoom = boundary; this.nextRoom = boundary;
@ -247,7 +247,7 @@ NeatoVacuumRobotAccessory.prototype = {
{ {
if (this.robot.canPause) if (this.robot.canPause)
{ {
debug(this.name + ": Pause cleaning"); debug(this.name + ": ## Pause cleaning");
this.robot.pauseCleaning(callback); this.robot.pauseCleaning(callback);
} }
else else
@ -275,7 +275,7 @@ NeatoVacuumRobotAccessory.prototype = {
let extraCare = this.vacuumRobotExtraCareService.getCharacteristic(Characteristic.On).value; let extraCare = this.vacuumRobotExtraCareService.getCharacteristic(Characteristic.On).value;
let nogoLines = this.vacuumRobotNoGoLinesService.getCharacteristic(Characteristic.On).value; let nogoLines = this.vacuumRobotNoGoLinesService.getCharacteristic(Characteristic.On).value;
let room = (typeof boundary === 'undefined') ? '' : boundary.name; let room = (typeof boundary === 'undefined') ? '' : boundary.name;
debug(this.name + ": Start cleaning (" + room + " eco: " + eco + ", extraCare: " + extraCare + ", nogoLines: " + nogoLines + ")"); debug(this.name + ": ## Start cleaning (" + room + " eco: " + eco + ", extraCare: " + extraCare + ", nogoLines: " + nogoLines + ")");
// Normal cleaning // Normal cleaning
if (typeof boundary === 'undefined') if (typeof boundary === 'undefined')
@ -328,19 +328,19 @@ NeatoVacuumRobotAccessory.prototype = {
{ {
if (this.robot.canPause) if (this.robot.canPause)
{ {
debug(this.name + ": Pause cleaning to go to dock"); debug(this.name + ": ## Pause cleaning to go to dock");
this.robot.pauseCleaning((error, result) => this.robot.pauseCleaning((error, result) =>
{ {
setTimeout(() => setTimeout(() =>
{ {
debug(this.name + ": Go to dock"); debug(this.name + ": ## Go to dock");
this.robot.sendToBase(callback); this.robot.sendToBase(callback);
}, 1000); }, 1000);
}); });
} }
else if (this.robot.canGoToBase) else if (this.robot.canGoToBase)
{ {
debug(this.name + ": Go to dock"); debug(this.name + ": ## Go to dock");
this.robot.sendToBase(callback); this.robot.sendToBase(callback);
} }
else else
@ -502,7 +502,7 @@ NeatoVacuumRobotAccessory.prototype = {
this.clean((error, result) => this.clean((error, result) =>
{ {
this.nextRoom = null; this.nextRoom = null;
debug("Starting cleaning of next room"); debug("## Starting cleaning of next room");
}, this.nextRoom); }, this.nextRoom);
} }
} }

View File

@ -58,6 +58,8 @@ NeatoVacuumRobotPlatform.prototype = {
this.robots.forEach((robot, i) => this.robots.forEach((robot, i) =>
{ {
this.log("Found robot #" + (i + 1) + " named \"" + robot.device.name + "\" with serial \"" + robot.device._serial + "\""); this.log("Found robot #" + (i + 1) + " named \"" + robot.device.name + "\" with serial \"" + robot.device._serial + "\"");
// Start Update Intervall
this.updateRobotTimer(robot.device._serial); this.updateRobotTimer(robot.device._serial);
let NeatoVacuumRobotAccessory = require('./accessories/neatoVacuumRobot')(Service, Characteristic); let NeatoVacuumRobotAccessory = require('./accessories/neatoVacuumRobot')(Service, Characteristic);
@ -162,14 +164,26 @@ NeatoVacuumRobotPlatform.prototype = {
// Robot is completely requested if all maps are requested // Robot is completely requested if all maps are requested
if (requestedMap === robot.maps.length) if (requestedMap === robot.maps.length)
{ {
this.robots.push({device: robot}); // Get additional information
requestedRobot++; robot.getState((error, result) =>
// Initial request is complete if all robots are requested.
if (requestedRobot === robots.length)
{ {
callback(); if (error)
} {
this.log.error("Error getting robot meta information: " + error + ": " + result);
callback();
}
else
{
this.robots.push({device: robot, meta: result.meta});
requestedRobot++;
// Initial request is complete if all robots are requested.
if (requestedRobot === robots.length)
{
callback();
}
}
});
} }
}) })
}); });
@ -194,7 +208,7 @@ NeatoVacuumRobotPlatform.prototype = {
else else
{ {
debug(robot.device.name + ": ++ Updating robot state"); debug(robot.device.name + ": ++ Updating robot state");
robot.device.getState(function (error, result) robot.device.getState((error, result) =>
{ {
if (error) if (error)
{ {