Removed lint check for beta
This commit is contained in:
parent
dea0d157eb
commit
a62972d022
@ -10,7 +10,8 @@
|
|||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"ignorePatterns": [
|
"ignorePatterns": [
|
||||||
"dist"
|
"dist",
|
||||||
|
"api.ts"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"quotes": ["warn", "double"],
|
"quotes": ["warn", "double"],
|
||||||
|
@ -17,8 +17,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint src/**.ts --max-warnings=0",
|
"lint": "eslint src/**.ts --max-warnings=0",
|
||||||
"watch": "npm run build && npm link && nodemon",
|
"watch": "npm run build && npm link && nodemon",
|
||||||
"build": "rimraf ./dist && tsc",
|
"build": "rimraf ./dist && tsc"
|
||||||
"prepublishOnly": "npm run lint && npm run build"
|
|
||||||
},
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Arne Blumentritt",
|
"name": "Arne Blumentritt",
|
||||||
|
78
src/api.ts
78
src/api.ts
@ -1,45 +1,51 @@
|
|||||||
var axios = require('axios');
|
var axios = require('axios');
|
||||||
|
|
||||||
function request(url, payload, method, headers, callback) {
|
function request(url, payload, method, headers, callback)
|
||||||
if (!url || url === '') {
|
{
|
||||||
if (typeof callback === 'function') callback('no url specified');
|
if (!url || url === '')
|
||||||
return;
|
{
|
||||||
}
|
if (typeof callback === 'function') callback('no url specified');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
data: null,
|
data: null,
|
||||||
method: method === 'GET' ? 'GET' : 'POST',
|
method: method === 'GET' ? 'GET' : 'POST',
|
||||||
url: url,
|
url: url,
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/vnd.neato.nucleo.v1'
|
'Accept': 'application/vnd.neato.nucleo.v1'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options.method === 'POST') {
|
if (options.method === 'POST')
|
||||||
options.data = payload;
|
{
|
||||||
}
|
options.data = payload;
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof headers === 'object') {
|
if (typeof headers === 'object')
|
||||||
for (var header in headers) {
|
{
|
||||||
if (headers.hasOwnProperty(header)) {
|
for (var header in headers)
|
||||||
options.headers[header] = headers[header];
|
{
|
||||||
}
|
if (headers.hasOwnProperty(header))
|
||||||
}
|
{
|
||||||
}
|
options.headers[header] = headers[header];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let res, err;
|
let res, err;
|
||||||
|
|
||||||
axios(options)
|
axios(options)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
res = response.data;
|
res = response.data;
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
err = error;
|
err = error;
|
||||||
})
|
})
|
||||||
.finally(function () {
|
.finally(function () {
|
||||||
// Callback needs to be called in finally block, see: https://github.com/Pmant/node-botvac/issues/15
|
// Callback needs to be called in finally block, see: https://github.com/Pmant/node-botvac/issues/15
|
||||||
if (typeof callback === 'function') callback(err, res);
|
if (typeof callback === 'function') callback(err, res);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.request = request;
|
exports.request = request;
|
||||||
|
@ -41,7 +41,7 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin
|
|||||||
discoverRobots()
|
discoverRobots()
|
||||||
{
|
{
|
||||||
const client = new NeatoApi.Client();
|
const client = new NeatoApi.Client();
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -57,20 +57,20 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin
|
|||||||
|
|
||||||
// Debug robot request TODO: remove after beta
|
// Debug robot request TODO: remove after beta
|
||||||
let that = this;
|
let that = this;
|
||||||
api.request(client._baseUrl + '/users/me/robots', null, 'GET', {Authorization: client._tokenType + client._token}, (function (error, result) {
|
api.request(client._baseUrl + "/users/me/robots", null, "GET", {Authorization: client._tokenType + client._token}, (function (error, result) {
|
||||||
result.forEach(r => {
|
result.forEach(r => {
|
||||||
r.serial = "xxx" + r.serial.length;
|
r.serial = "xxx" + r.serial.length;
|
||||||
r.secret_key = "xxx" + r.secret_key.length;
|
r.secret_key = "xxx" + r.secret_key.length;
|
||||||
r.mac_address = "xxx" + r.mac_address.length;
|
r.mac_address = "xxx" + r.mac_address.length;
|
||||||
that.log.debug("Robot Request Result: " + JSON.stringify(r));
|
that.log.debug("Robot Request Result: " + JSON.stringify(r));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
that.log.debug("Robot Request Error: " + JSON.stringify(error));
|
that.log.debug("Robot Request Error: " + JSON.stringify(error));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Get all robots from account
|
// Get all robots from account
|
||||||
client.getRobots((error, robots) => {
|
client.getRobots((error, robots) => {
|
||||||
if (error)
|
if (error)
|
||||||
@ -112,7 +112,7 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin
|
|||||||
// Check if robot already exists as an accessory
|
// Check if robot already exists as an accessory
|
||||||
const uuid = this.api.hap.uuid.generate(robot._serial);
|
const uuid = this.api.hap.uuid.generate(robot._serial);
|
||||||
const cachedRobot = this.cachedRobotAccessories.find(accessory => accessory.UUID === uuid);
|
const cachedRobot = this.cachedRobotAccessories.find(accessory => accessory.UUID === uuid);
|
||||||
|
|
||||||
if (cachedRobot)
|
if (cachedRobot)
|
||||||
{
|
{
|
||||||
this.log.debug("[" + robot.name + "] Updating meta information for robot in cache.");
|
this.log.debug("[" + robot.name + "] Updating meta information for robot in cache.");
|
||||||
@ -147,7 +147,7 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO get maps
|
// TODO get maps
|
||||||
|
|
||||||
const newRobot = new this.api.platformAccessory(robot.name, uuid);
|
const newRobot = new this.api.platformAccessory(robot.name, uuid);
|
||||||
newRobot.context.robot = robot;
|
newRobot.context.robot = robot;
|
||||||
new NeatoVacuumRobotAccessory(this, newRobot, this.config);
|
new NeatoVacuumRobotAccessory(this, newRobot, this.config);
|
||||||
|
Loading…
Reference in New Issue
Block a user