Removed beta debug information

This commit is contained in:
Arne Blumentritt 2021-05-05 12:06:54 +02:00
parent a62972d022
commit 94b3cc143f
2 changed files with 4 additions and 73 deletions

View File

@ -1,51 +0,0 @@
var axios = require('axios');
function request(url, payload, method, headers, callback)
{
if (!url || url === '')
{
if (typeof callback === 'function') callback('no url specified');
return;
}
var options = {
data: null,
method: method === 'GET' ? 'GET' : 'POST',
url: url,
headers: {
'Accept': 'application/vnd.neato.nucleo.v1'
}
};
if (options.method === 'POST')
{
options.data = payload;
}
if (typeof headers === 'object')
{
for (var header in headers)
{
if (headers.hasOwnProperty(header))
{
options.headers[header] = headers[header];
}
}
}
let res, err;
axios(options)
.then(function (response) {
res = response.data;
})
.catch(function (error) {
err = error;
})
.finally(function () {
// Callback needs to be called in finally block, see: https://github.com/Pmant/node-botvac/issues/15
if (typeof callback === 'function') callback(err, res);
});
}
exports.request = request;

View File

@ -3,8 +3,6 @@ import NeatoApi from "node-botvac";
import {PLATFORM_NAME, PLUGIN_NAME} from "./settings"; import {PLATFORM_NAME, PLUGIN_NAME} from "./settings";
import {NeatoVacuumRobotAccessory} from "./accessories/NeatoVacuumRobot"; import {NeatoVacuumRobotAccessory} from "./accessories/NeatoVacuumRobot";
const api = require("./api");
/** /**
* HomebridgePlatform * HomebridgePlatform
* This class is the main constructor for your plugin, this is where you should * This class is the main constructor for your plugin, this is where you should
@ -55,22 +53,6 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin
return; return;
} }
// Debug robot request TODO: remove after beta
let that = this;
api.request(client._baseUrl + "/users/me/robots", null, "GET", {Authorization: client._tokenType + client._token}, (function (error, result) {
result.forEach(r => {
r.serial = "xxx" + r.serial.length;
r.secret_key = "xxx" + r.secret_key.length;
r.mac_address = "xxx" + r.mac_address.length;
that.log.debug("Robot Request Result: " + JSON.stringify(r));
});
if (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)
@ -115,17 +97,17 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin
if (cachedRobot) if (cachedRobot)
{ {
this.log.debug("[" + robot.name + "] Updating meta information for robot in cache."); this.log.debug("[" + robot.name + "] Connecting to cached robot and updating information.");
} }
else else
{ {
this.log.debug("[" + robot.name + "] Getting meta information for new robot."); this.log.debug("[" + robot.name + "] Connecting to new robot and updating information.");
} }
robot.getState((error, state) => { robot.getState((error, state) => {
if (error) if (error)
{ {
this.log.error("[" + robot.name + "] Error getting meta information. Is the robot connected to the internet? Error: " + error + ". State: " + state); this.log.error("[" + robot.name + "] Cannot connect to robot. Is the robot connected to the internet? Error: " + error + ". State: " + state);
} }
else else
{ {
@ -141,7 +123,7 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin
cachedRobot.context.robot = robot; cachedRobot.context.robot = robot;
this.api.updatePlatformAccessories([cachedRobot]); this.api.updatePlatformAccessories([cachedRobot]);
new NeatoVacuumRobotAccessory(this, cachedRobot, this.config); new NeatoVacuumRobotAccessory(this, cachedRobot, this.config);
this.log.info("[" + robot.name + "] Successfully loaded from cache"); this.log.info("[" + robot.name + "] Successfully loaded robot from cache");
} }
// Create new robot accessory // Create new robot accessory
else else