Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
92eabfe5cd | ||
|
67b930653f | ||
|
579bd32a93 | ||
|
a606d4c632 | ||
|
3a4327f7e9 | ||
|
cbfbb26b14 |
17
.gitattributes
vendored
17
.gitattributes
vendored
@@ -1,17 +0,0 @@
|
|||||||
# Auto detect text files and perform LF normalization
|
|
||||||
* text=auto
|
|
||||||
|
|
||||||
# Custom for Visual Studio
|
|
||||||
*.cs diff=csharp
|
|
||||||
|
|
||||||
# Standard to msysgit
|
|
||||||
*.doc diff=astextplain
|
|
||||||
*.DOC diff=astextplain
|
|
||||||
*.docx diff=astextplain
|
|
||||||
*.DOCX diff=astextplain
|
|
||||||
*.dot diff=astextplain
|
|
||||||
*.DOT diff=astextplain
|
|
||||||
*.pdf diff=astextplain
|
|
||||||
*.PDF diff=astextplain
|
|
||||||
*.rtf diff=astextplain
|
|
||||||
*.RTF diff=astextplain
|
|
47
.gitignore
vendored
47
.gitignore
vendored
@@ -1,47 +0,0 @@
|
|||||||
# Windows image file caches
|
|
||||||
Thumbs.db
|
|
||||||
ehthumbs.db
|
|
||||||
|
|
||||||
# Folder config file
|
|
||||||
Desktop.ini
|
|
||||||
|
|
||||||
# Recycle Bin used on file shares
|
|
||||||
$RECYCLE.BIN/
|
|
||||||
|
|
||||||
# Windows Installer files
|
|
||||||
*.cab
|
|
||||||
*.msi
|
|
||||||
*.msm
|
|
||||||
*.msp
|
|
||||||
|
|
||||||
# Windows shortcuts
|
|
||||||
*.lnk
|
|
||||||
|
|
||||||
# =========================
|
|
||||||
# Operating System Files
|
|
||||||
# =========================
|
|
||||||
|
|
||||||
# OSX
|
|
||||||
# =========================
|
|
||||||
|
|
||||||
.DS_Store
|
|
||||||
.AppleDouble
|
|
||||||
.LSOverride
|
|
||||||
|
|
||||||
# Thumbnails
|
|
||||||
._*
|
|
||||||
|
|
||||||
# Files that might appear in the root of a volume
|
|
||||||
.DocumentRevisions-V100
|
|
||||||
.fseventsd
|
|
||||||
.Spotlight-V100
|
|
||||||
.TemporaryItems
|
|
||||||
.Trashes
|
|
||||||
.VolumeIcon.icns
|
|
||||||
|
|
||||||
# Directories potentially created on remote AFP share
|
|
||||||
.AppleDB
|
|
||||||
.AppleDesktop
|
|
||||||
Network Trash Folder
|
|
||||||
Temporary Items
|
|
||||||
.apdisk
|
|
@@ -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
|
50
README.md
50
README.md
@@ -1,40 +1,42 @@
|
|||||||
# homebridge-neato
|
# homebridge-neato
|
||||||
|
|
||||||
This is a plugin to control your [Neato](https://www.neatorobotics.com/) vacuum robot.
|
This is a plugin for [homebridge](https://github.com/nfarina/homebridge) to control your [Neato](https://www.neatorobotics.com/) vacuum robot. You can download it via [npm](https://www.npmjs.com/package/homebridge-neato).
|
||||||
|
|
||||||
|
Feel free to leave any feedback [here](https://github.com/naofireblade/homebridge-neato/issues).
|
||||||
|
|
||||||
|
# Features
|
||||||
|
|
||||||
|
- Start and pause cleaning
|
||||||
|
- Return to dock
|
||||||
|
- Enable and disable schedule
|
||||||
|
- Enable and disable eco mode
|
||||||
|
- Get battery info
|
||||||
|
- Get dock info
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
1. Install homebridge using: npm install -g homebridge
|
1. Install homebridge using: `npm install -g homebridge`
|
||||||
2. Install this plugin using: npm install -g homebridge-neato
|
2. Install this plugin using: `npm install -g homebridge-neato`
|
||||||
3. Update your configuration file. See the sample below.
|
3. If you don't have a Neato account yet create one [here](https://www.neatorobotics.com/create-account/).
|
||||||
|
4. Update your configuration file. See the sample below.
|
||||||
|
|
||||||
# Configuration
|
### Configuration
|
||||||
|
|
||||||
Configuration sample:
|
|
||||||
|
|
||||||
Add the following information to your config file. Change the values for name, email and password.
|
Add the following information to your config file. Change the values for name, email and password.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"accessories": [
|
"accessories": [
|
||||||
{
|
{
|
||||||
"accessory": "NeatoVacuumRobot",
|
"accessory": "NeatoVacuumRobot",
|
||||||
"name": "YourRobot",
|
"name": "YourRobot",
|
||||||
"email": "YourEmail",
|
"email": "YourEmail",
|
||||||
"password": "YourPassword"
|
"password": "YourPassword"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
# Features
|
|
||||||
|
|
||||||
- Atart and pause cleaning
|
|
||||||
- Return to base
|
|
||||||
- Enable and disable schedule
|
|
||||||
- Enable and disable eco mode
|
|
||||||
- Get battery info
|
|
||||||
|
|
||||||
# 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) 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();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
11
package.json
11
package.json
@@ -1,10 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "homebridge-neato",
|
"name": "homebridge-neato",
|
||||||
"version": "0.1.0",
|
"version": "0.2.0",
|
||||||
"description": "control your neato vacuum robot",
|
"description": "A Neato vacuum robot plugin for homebridge.",
|
||||||
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user