Version 0.2.0
* Added dock info * Changed logging to debug library
This commit is contained in:
parent
3a4327f7e9
commit
a606d4c632
@ -4,4 +4,9 @@
|
|||||||
* Added return to base
|
* Added return to base
|
||||||
* Added enable and disable schedule
|
* Added enable and disable schedule
|
||||||
* Added enable and disable eco mode
|
* Added enable and disable eco mode
|
||||||
* Added battery info
|
* Added battery info
|
||||||
|
|
||||||
|
## 0.2.0
|
||||||
|
|
||||||
|
* Added dock info
|
||||||
|
* Changed logging to debug library
|
@ -35,6 +35,6 @@ Add the following information to your config file. Change the values for name, e
|
|||||||
|
|
||||||
# Tested robots
|
# Tested robots
|
||||||
|
|
||||||
- BotVac Connected Firmware 2.2.0
|
- BotVac Connected (Firmware 2.2.0)
|
||||||
|
|
||||||
If you have another connected neato robot, please [tell me](https://github.com/naofireblade/homebridge-neato/issues/new) your experience with this plugin.
|
If you have another connected neato robot, please [tell me](https://github.com/naofireblade/homebridge-neato/issues/new) your experience with this plugin.
|
||||||
|
63
index.js
63
index.js
@ -1,5 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var inherits = require('util').inherits;
|
var inherits = require('util').inherits;
|
||||||
|
var debug = require('debug')('homebridge-neato');
|
||||||
var botvac = require('node-botvac');
|
var botvac = require('node-botvac');
|
||||||
|
|
||||||
var Service, Characteristic;
|
var Service, Characteristic;
|
||||||
@ -38,9 +39,12 @@ NeatoVacuumRobot.prototype = {
|
|||||||
this.vacuumRobotCleanService.getCharacteristic(Characteristic.On).on('set', this.clean.bind(this));
|
this.vacuumRobotCleanService.getCharacteristic(Characteristic.On).on('set', this.clean.bind(this));
|
||||||
this.vacuumRobotCleanService.getCharacteristic(Characteristic.On).on('get', this.getClean.bind(this));
|
this.vacuumRobotCleanService.getCharacteristic(Characteristic.On).on('get', this.getClean.bind(this));
|
||||||
|
|
||||||
this.vacuumRobotDockService = new Service.Switch(this.name + " Dock", "dock");
|
this.vacuumRobotGoToDockService = new Service.Switch(this.name + " Go to Dock", "goToDock");
|
||||||
this.vacuumRobotDockService.getCharacteristic(Characteristic.On).on('set', this.dock.bind(this));
|
this.vacuumRobotGoToDockService.getCharacteristic(Characteristic.On).on('set', this.dock.bind(this));
|
||||||
this.vacuumRobotDockService.getCharacteristic(Characteristic.On).on('get', this.getDock.bind(this));
|
this.vacuumRobotGoToDockService.getCharacteristic(Characteristic.On).on('get', this.getCanGoToDock.bind(this));
|
||||||
|
|
||||||
|
this.vacuumRobotDockStateService = new Service.OccupancySensor(this.name + " Dock", "dockState");
|
||||||
|
this.vacuumRobotDockStateService.getCharacteristic(Characteristic.OccupancyDetected).on('get', this.getDockState.bind(this));
|
||||||
|
|
||||||
this.vacuumRobotEcoService = new Service.Switch(this.name + " Eco Mode", "eco");
|
this.vacuumRobotEcoService = new Service.Switch(this.name + " Eco Mode", "eco");
|
||||||
this.vacuumRobotEcoService.getCharacteristic(Characteristic.On).on('set', this.eco.bind(this));
|
this.vacuumRobotEcoService.getCharacteristic(Characteristic.On).on('set', this.eco.bind(this));
|
||||||
@ -54,7 +58,7 @@ NeatoVacuumRobot.prototype = {
|
|||||||
this.vacuumRobotBatteryService.getCharacteristic(Characteristic.BatteryLevel).on('get', this.getBatteryLevel.bind(this));
|
this.vacuumRobotBatteryService.getCharacteristic(Characteristic.BatteryLevel).on('get', this.getBatteryLevel.bind(this));
|
||||||
this.vacuumRobotBatteryService.getCharacteristic(Characteristic.ChargingState).on('get', this.getBatteryChargingState.bind(this));
|
this.vacuumRobotBatteryService.getCharacteristic(Characteristic.ChargingState).on('get', this.getBatteryChargingState.bind(this));
|
||||||
|
|
||||||
return [this.informationService, this.vacuumRobotCleanService, this.vacuumRobotDockService, this.vacuumRobotEcoService,
|
return [this.informationService, this.vacuumRobotCleanService, this.vacuumRobotGoToDockService, this.vacuumRobotDockStateService, this.vacuumRobotEcoService,
|
||||||
this.vacuumRobotScheduleService, this.vacuumRobotBatteryService];
|
this.vacuumRobotScheduleService, this.vacuumRobotBatteryService];
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -62,15 +66,14 @@ NeatoVacuumRobot.prototype = {
|
|||||||
let that = this;
|
let that = this;
|
||||||
if (on) {
|
if (on) {
|
||||||
this.getState(function (error, result) {
|
this.getState(function (error, result) {
|
||||||
that.log(that.robot);
|
|
||||||
if (that.robot.canResume === true) {
|
if (that.robot.canResume === true) {
|
||||||
that.log("Resume cleaning");
|
debug("Resume cleaning");
|
||||||
that.robot.resumeCleaning(function (error, result) {
|
that.robot.resumeCleaning(function (error, result) {
|
||||||
that.log(result);
|
that.log(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
that.log("Start cleaning");
|
debug("Start cleaning");
|
||||||
that.robot.startCleaning(that.robot.eco, function (error, result) {
|
that.robot.startCleaning(that.robot.eco, function (error, result) {
|
||||||
that.log(result);
|
that.log(result);
|
||||||
});
|
});
|
||||||
@ -78,7 +81,7 @@ NeatoVacuumRobot.prototype = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.log("Pause cleaning");
|
debug("Pause cleaning");
|
||||||
this.robot.pauseCleaning(false, function (error, result) {
|
this.robot.pauseCleaning(false, function (error, result) {
|
||||||
that.log(result);
|
that.log(result);
|
||||||
});
|
});
|
||||||
@ -88,9 +91,8 @@ NeatoVacuumRobot.prototype = {
|
|||||||
|
|
||||||
dock: function (on, callback) {
|
dock: function (on, callback) {
|
||||||
let that = this;
|
let that = this;
|
||||||
that.log(that.robot);
|
|
||||||
if (on) {
|
if (on) {
|
||||||
that.log("Send to dock");
|
debug("Go to dock");
|
||||||
that.robot.sendToBase(false, function (error, result) {
|
that.robot.sendToBase(false, function (error, result) {
|
||||||
that.log(result);
|
that.log(result);
|
||||||
});
|
});
|
||||||
@ -99,22 +101,23 @@ NeatoVacuumRobot.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
eco: function (on, callback) {
|
eco: function (on, callback) {
|
||||||
this.log(on ? "Enable eco mode" : "Disable eco mode");
|
debug(on ? "Enable eco mode" : "Disable eco mode");
|
||||||
this.robot.eco = on;
|
this.robot.eco = on;
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
|
|
||||||
schedule: function (on, callback) {
|
schedule: function (on, callback) {
|
||||||
|
let that = this;
|
||||||
if (on) {
|
if (on) {
|
||||||
this.log("Enable schedule");
|
debug("Enable schedule");
|
||||||
this.robot.enableSchedule(false, function (error, result) {
|
this.robot.enableSchedule(false, function (error, result) {
|
||||||
onsole.log(result);
|
that.log(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.log("Disable schedule");
|
debug("Disable schedule");
|
||||||
this.robot.disableSchedule(false, function (error, result) {
|
this.robot.disableSchedule(false, function (error, result) {
|
||||||
onsole.log(result);
|
that.log(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
@ -123,16 +126,23 @@ NeatoVacuumRobot.prototype = {
|
|||||||
getClean: function(callback) {
|
getClean: function(callback) {
|
||||||
let that = this;
|
let that = this;
|
||||||
this.getState(function (error, result) {
|
this.getState(function (error, result) {
|
||||||
that.log("Is cleaning: " + that.robot.canPause);
|
debug("Is cleaning: " + that.robot.canPause);
|
||||||
callback(false, that.robot.canPause);
|
callback(false, that.robot.canPause);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getDock: function(callback) {
|
getCanGoToDock: function(callback) {
|
||||||
let that = this;
|
let that = this;
|
||||||
this.getState(function (error, result) {
|
this.getState(function (error, result) {
|
||||||
that.log("Can go to dock: " + that.robot.canGoToBase);
|
debug("Can go to dock: " + that.robot.canGoToBase);
|
||||||
that.log("Is docked: " + that.robot.isDocked);
|
callback(false, !that.robot.canGoToBase);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
getDockState: function(callback) {
|
||||||
|
let that = this;
|
||||||
|
this.getState(function (error, result) {
|
||||||
|
debug("Is docked: " + that.robot.isDocked);
|
||||||
callback(false, that.robot.isDocked);
|
callback(false, that.robot.isDocked);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -140,7 +150,7 @@ NeatoVacuumRobot.prototype = {
|
|||||||
getEco: function(callback) {
|
getEco: function(callback) {
|
||||||
let that = this;
|
let that = this;
|
||||||
this.getState(function (error, result) {
|
this.getState(function (error, result) {
|
||||||
that.log("Eco mode: " + that.robot.eco);
|
debug("Eco mode: " + that.robot.eco);
|
||||||
callback(false, that.robot.eco);
|
callback(false, that.robot.eco);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -148,7 +158,7 @@ NeatoVacuumRobot.prototype = {
|
|||||||
getSchedule: function(callback) {
|
getSchedule: function(callback) {
|
||||||
let that = this;
|
let that = this;
|
||||||
this.getState(function (error, result) {
|
this.getState(function (error, result) {
|
||||||
that.log("Schedule: " + that.robot.isScheduleEnabled);
|
debug("Schedule: " + that.robot.isScheduleEnabled);
|
||||||
callback(false, that.robot.isScheduleEnabled);
|
callback(false, that.robot.isScheduleEnabled);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -157,7 +167,7 @@ NeatoVacuumRobot.prototype = {
|
|||||||
getBatteryLevel: function(callback) {
|
getBatteryLevel: function(callback) {
|
||||||
let that = this;
|
let that = this;
|
||||||
this.getState(function (error, result) {
|
this.getState(function (error, result) {
|
||||||
that.log("Battery: " + that.robot.charge);
|
debug("Battery: " + that.robot.charge);
|
||||||
callback(false, that.robot.charge);
|
callback(false, that.robot.charge);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -165,7 +175,7 @@ NeatoVacuumRobot.prototype = {
|
|||||||
getBatteryChargingState: function(callback) {
|
getBatteryChargingState: function(callback) {
|
||||||
let that = this;
|
let that = this;
|
||||||
this.getState(function (error, result) {
|
this.getState(function (error, result) {
|
||||||
that.log("Is charging: " + that.robot.isCharging);
|
debug("Is charging: " + that.robot.isCharging);
|
||||||
callback(false, that.robot.isCharging);
|
callback(false, that.robot.isCharging);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -185,11 +195,11 @@ NeatoVacuumRobot.prototype = {
|
|||||||
|
|
||||||
_getState: function(callback) {
|
_getState: function(callback) {
|
||||||
if (this.lastUpdate !== null && new Date() - this.lastUpdate < 2000) {
|
if (this.lastUpdate !== null && new Date() - this.lastUpdate < 2000) {
|
||||||
//this.log("Get state (cached)");
|
debug("Get info (cached)");
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//this.log("Get state (new)");
|
debug("Get info (new)");
|
||||||
let that = this;
|
let that = this;
|
||||||
this.robot.getState(function (error, result) {
|
this.robot.getState(function (error, result) {
|
||||||
that.lastUpdate = new Date();
|
that.lastUpdate = new Date();
|
||||||
@ -199,7 +209,7 @@ NeatoVacuumRobot.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getRobot: function(callback) {
|
getRobot: function(callback) {
|
||||||
//this.log("Get robot");
|
debug("Get robot");
|
||||||
let client = new botvac.Client();
|
let client = new botvac.Client();
|
||||||
let that = this;
|
let that = this;
|
||||||
client.authorize(this.email, this.password, false, function (error) {
|
client.authorize(this.email, this.password, false, function (error) {
|
||||||
@ -214,6 +224,7 @@ NeatoVacuumRobot.prototype = {
|
|||||||
else {
|
else {
|
||||||
that.robot = robots[0];
|
that.robot = robots[0];
|
||||||
that.log("Found robot: " + that.robot.name);
|
that.log("Found robot: " + that.robot.name);
|
||||||
|
debug(that.robot);
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "homebridge-neato",
|
"name": "homebridge-neato",
|
||||||
"version": "0.1.1",
|
"version": "0.2.0",
|
||||||
"description": "control your neato vacuum robot",
|
"description": "control your neato vacuum robot",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"homebridge-plugin"
|
"homebridge-plugin",
|
||||||
|
"neato",
|
||||||
|
"botvac"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.12.0",
|
"node": ">=0.12.0",
|
||||||
@ -18,6 +20,7 @@
|
|||||||
"url": "git://github.com/naofireblade/homebridge-neato.git"
|
"url": "git://github.com/naofireblade/homebridge-neato.git"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"node-botvac": ">=0.1.4"
|
"node-botvac": "^0.1.4",
|
||||||
|
"debug": "^2.2.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user