adapt for node-kobold-control api
This commit is contained in:
parent
49e3fdf191
commit
a99359f6ac
@ -1,4 +1,4 @@
|
|||||||
const debug = require('debug')('homebridge-neato');
|
const debug = require('debug')('homebridge-kobold');
|
||||||
const colors = require('colors');
|
const colors = require('colors');
|
||||||
|
|
||||||
const CustomUUID = {
|
const CustomUUID = {
|
||||||
@ -21,10 +21,10 @@ module.exports = function (_Service, _Characteristic)
|
|||||||
SpotHeightCharacteristic = require('../characteristics/spotHeight')(Characteristic, CustomUUID);
|
SpotHeightCharacteristic = require('../characteristics/spotHeight')(Characteristic, CustomUUID);
|
||||||
SpotRepeatCharacteristic = require('../characteristics/spotRepeat')(Characteristic, CustomUUID);
|
SpotRepeatCharacteristic = require('../characteristics/spotRepeat')(Characteristic, CustomUUID);
|
||||||
|
|
||||||
return NeatoVacuumRobotAccessory;
|
return KoboldVacuumRobotAccessory;
|
||||||
};
|
};
|
||||||
|
|
||||||
function NeatoVacuumRobotAccessory(platform, robotObject)
|
function KoboldVacuumRobotAccessory(platform, robotObject)
|
||||||
{
|
{
|
||||||
this.platform = platform;
|
this.platform = platform;
|
||||||
this.log = platform.log;
|
this.log = platform.log;
|
||||||
@ -99,7 +99,7 @@ function NeatoVacuumRobotAccessory(platform, robotObject)
|
|||||||
this.log("Added cleaning device named: " + this.name);
|
this.log("Added cleaning device named: " + this.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
NeatoVacuumRobotAccessory.prototype = {
|
KoboldVacuumRobotAccessory.prototype = {
|
||||||
identify: function (callback)
|
identify: function (callback)
|
||||||
{
|
{
|
||||||
this.robot.getState((error, result) =>
|
this.robot.getState((error, result) =>
|
||||||
@ -121,7 +121,7 @@ NeatoVacuumRobotAccessory.prototype = {
|
|||||||
{
|
{
|
||||||
this.informationService = new Service.AccessoryInformation();
|
this.informationService = new Service.AccessoryInformation();
|
||||||
this.informationService
|
this.informationService
|
||||||
.setCharacteristic(Characteristic.Manufacturer, "Neato Robotics")
|
.setCharacteristic(Characteristic.Manufacturer, "Vorwerk Deutschland Stiftung & Co. KG")
|
||||||
.setCharacteristic(Characteristic.Model, this.meta.modelName)
|
.setCharacteristic(Characteristic.Model, this.meta.modelName)
|
||||||
.setCharacteristic(Characteristic.SerialNumber, this.robot._serial)
|
.setCharacteristic(Characteristic.SerialNumber, this.robot._serial)
|
||||||
.setCharacteristic(Characteristic.FirmwareRevision, this.meta.firmware)
|
.setCharacteristic(Characteristic.FirmwareRevision, this.meta.firmware)
|
@ -1,22 +1,15 @@
|
|||||||
{
|
{
|
||||||
"pluginAlias": "NeatoVacuumRobot",
|
"pluginAlias": "KoboldVacuumRobot",
|
||||||
"pluginType": "platform",
|
"pluginType": "platform",
|
||||||
"headerDisplay": "For Advanced settings like Refresh time interval or Disabled switches/sensors. [Check Here](https://github.com/naofireblade/homebridge-neato#readme)",
|
"headerDisplay": "For Advanced settings like Refresh time interval or Disabled switches/sensors. [Check Here](https://github.com/himbeles/homebridge-kobold#readme)",
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"email": {
|
"token": {
|
||||||
"title": "email",
|
"title": "token",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"required": true,
|
"required": true,
|
||||||
"format": "email",
|
"description": "Your Token"
|
||||||
"description": "Your Email Address"
|
|
||||||
},
|
|
||||||
"password": {
|
|
||||||
"title": "password",
|
|
||||||
"type": "string",
|
|
||||||
"required": true,
|
|
||||||
"description": "Your Password"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
39
index.js
39
index.js
@ -1,26 +1,25 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
let inherits = require('util').inherits,
|
let inherits = require('util').inherits,
|
||||||
debug = require('debug')('homebridge-neato'),
|
debug = require('debug')('homebridge-kobold'),
|
||||||
botvac = require('node-botvac'),
|
control = require('node-kobold-control'),
|
||||||
|
|
||||||
Service,
|
Service,
|
||||||
Characteristic,
|
Characteristic,
|
||||||
NeatoVacuumRobotAccessory;
|
KoboldVacuumRobotAccessory;
|
||||||
|
|
||||||
module.exports = function (homebridge)
|
module.exports = function (homebridge)
|
||||||
{
|
{
|
||||||
Service = homebridge.hap.Service;
|
Service = homebridge.hap.Service;
|
||||||
Characteristic = homebridge.hap.Characteristic;
|
Characteristic = homebridge.hap.Characteristic;
|
||||||
NeatoVacuumRobotAccessory = require('./accessories/neatoVacuumRobot')(Service, Characteristic);
|
KoboldVacuumRobotAccessory = require('./accessories/koboldVacuumRobot')(Service, Characteristic);
|
||||||
homebridge.registerPlatform("homebridge-neato", "NeatoVacuumRobot", NeatoVacuumRobotPlatform);
|
homebridge.registerPlatform("homebridge-kobold", "KoboldVacuumRobot", KoboldVacuumRobotPlatform);
|
||||||
};
|
};
|
||||||
|
|
||||||
function NeatoVacuumRobotPlatform(log, config)
|
function KoboldVacuumRobotPlatform(log, config)
|
||||||
{
|
{
|
||||||
this.log = log;
|
this.log = log;
|
||||||
this.serial = "1-3-3-7";
|
this.serial = "1-3-3-7";
|
||||||
this.email = config['email'];
|
this.token = config['token'];
|
||||||
this.password = config['password'];
|
|
||||||
this.hiddenServices = '';
|
this.hiddenServices = '';
|
||||||
this.hiddenServices = ('disabled' in config ? config['disabled'] : this.hiddenServices);
|
this.hiddenServices = ('disabled' in config ? config['disabled'] : this.hiddenServices);
|
||||||
this.hiddenServices = ('hidden' in config ? config['hidden'] : this.hiddenServices);
|
this.hiddenServices = ('hidden' in config ? config['hidden'] : this.hiddenServices);
|
||||||
@ -35,10 +34,10 @@ function NeatoVacuumRobotPlatform(log, config)
|
|||||||
this.refresh = parseInt(config['refresh']);
|
this.refresh = parseInt(config['refresh']);
|
||||||
// must be integer and positive
|
// must be integer and positive
|
||||||
this.refresh = (typeof this.refresh !== 'number' || (this.refresh % 1) !== 0 || this.refresh < 0) ? 60 : this.refresh;
|
this.refresh = (typeof this.refresh !== 'number' || (this.refresh % 1) !== 0 || this.refresh < 0) ? 60 : this.refresh;
|
||||||
// minimum 60s to save some load on the neato servers
|
// minimum 60s to save some load on the Vorwerk servers
|
||||||
if (this.refresh > 0 && this.refresh < 60)
|
if (this.refresh > 0 && this.refresh < 60)
|
||||||
{
|
{
|
||||||
this.log.warn("Minimum refresh time is 60 seconds to not overload the neato servers");
|
this.log.warn("Minimum refresh time is 60 seconds to not overload the Vorwerk servers");
|
||||||
this.refresh = (this.refresh > 0 && this.refresh < 60) ? 60 : this.refresh;
|
this.refresh = (this.refresh > 0 && this.refresh < 60) ? 60 : this.refresh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,7 +49,7 @@ function NeatoVacuumRobotPlatform(log, config)
|
|||||||
this.log("Refresh is set to: " + this.refresh + (this.refresh !== 'auto' ? ' seconds' : ''));
|
this.log("Refresh is set to: " + this.refresh + (this.refresh !== 'auto' ? ' seconds' : ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
NeatoVacuumRobotPlatform.prototype = {
|
KoboldVacuumRobotPlatform.prototype = {
|
||||||
accessories: function (callback)
|
accessories: function (callback)
|
||||||
{
|
{
|
||||||
debug("Get robots");
|
debug("Get robots");
|
||||||
@ -60,8 +59,8 @@ NeatoVacuumRobotPlatform.prototype = {
|
|||||||
this.getRobots(() =>
|
this.getRobots(() =>
|
||||||
{
|
{
|
||||||
// // MOCK MULTIPLE ROBOTS START
|
// // MOCK MULTIPLE ROBOTS START
|
||||||
// let client = new botvac.Client();
|
// let client = new control.Client();
|
||||||
// client.authorize(this.email, this.password, false, (error) =>
|
// client.authorize(this.token, (error) =>
|
||||||
// {
|
// {
|
||||||
// client.getRobots((error, robs) =>
|
// client.getRobots((error, robs) =>
|
||||||
// {
|
// {
|
||||||
@ -76,7 +75,7 @@ NeatoVacuumRobotPlatform.prototype = {
|
|||||||
{
|
{
|
||||||
this.log("Found robot #" + (i + 1) + " named \"" + robot.device.name + "\" with serial \"" + robot.device._serial.substring(0, 9) + "XXXXXXXXXXXX\"");
|
this.log("Found robot #" + (i + 1) + " named \"" + robot.device.name + "\" with serial \"" + robot.device._serial.substring(0, 9) + "XXXXXXXXXXXX\"");
|
||||||
|
|
||||||
let mainAccessory = new NeatoVacuumRobotAccessory(this, robot);
|
let mainAccessory = new KoboldVacuumRobotAccessory(this, robot);
|
||||||
accessories.push(mainAccessory);
|
accessories.push(mainAccessory);
|
||||||
|
|
||||||
robot.mainAccessory = mainAccessory;
|
robot.mainAccessory = mainAccessory;
|
||||||
@ -87,7 +86,7 @@ NeatoVacuumRobotPlatform.prototype = {
|
|||||||
|
|
||||||
// // MOCK ZONE CLEANING START
|
// // MOCK ZONE CLEANING START
|
||||||
// robot.boundary = {name: "Testroom", id: "1"};
|
// robot.boundary = {name: "Testroom", id: "1"};
|
||||||
// let roomAccessory = new NeatoVacuumRobotAccessory(this, robot);
|
// let roomAccessory = new KoboldVacuumRobotAccessory(this, robot);
|
||||||
// accessories.push(roomAccessory);
|
// accessories.push(roomAccessory);
|
||||||
// robot.roomAccessories.push(roomAccessory);
|
// robot.roomAccessories.push(roomAccessory);
|
||||||
// // MOCK ZONE CLEANING END
|
// // MOCK ZONE CLEANING END
|
||||||
@ -103,7 +102,7 @@ NeatoVacuumRobotPlatform.prototype = {
|
|||||||
if (boundary.type === "polygon")
|
if (boundary.type === "polygon")
|
||||||
{
|
{
|
||||||
robot.boundary = boundary;
|
robot.boundary = boundary;
|
||||||
let roomAccessory = new NeatoVacuumRobotAccessory(this, robot);
|
let roomAccessory = new KoboldVacuumRobotAccessory(this, robot);
|
||||||
accessories.push(roomAccessory);
|
accessories.push(roomAccessory);
|
||||||
|
|
||||||
robot.roomAccessories.push(roomAccessory);
|
robot.roomAccessories.push(roomAccessory);
|
||||||
@ -126,14 +125,14 @@ NeatoVacuumRobotPlatform.prototype = {
|
|||||||
getRobots: function (callback)
|
getRobots: function (callback)
|
||||||
{
|
{
|
||||||
debug("Loading your robots");
|
debug("Loading your robots");
|
||||||
let client = new botvac.Client();
|
let client = new control.Client();
|
||||||
|
|
||||||
// Login
|
// Login
|
||||||
client.authorize(this.email, this.password, false, (error) =>
|
client.authorize(this.token, (error) =>
|
||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
this.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: " + error);
|
this.log.error("Can't log on to Vorwerk cloud. Please check your internet connection and your token. Try again later if the Vorwerk servers have issues: " + error);
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -143,7 +142,7 @@ NeatoVacuumRobotPlatform.prototype = {
|
|||||||
{
|
{
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
this.log.error("Successful login but can't connect to your neato robot: " + error);
|
this.log.error("Successful login but can't connect to your Vorwerk robot: " + error);
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
else if (robots.length === 0)
|
else if (robots.length === 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user