Skip to content

Commit

Permalink
Update jeedom-api.js
Browse files Browse the repository at this point in the history
  • Loading branch information
NebzHB authored Jan 24, 2024
1 parent 586b2a9 commit 88cd069
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions lib/jeedom-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
const axios = require('axios');
const async = require('async');
var DEV_DEBUG;
var USE_QUEUES=true;

function JeedomClient(url, apikey, Plateform, myPlugin) {
this.apikey = apikey;
Expand All @@ -30,12 +31,12 @@ function JeedomClient(url, apikey, Plateform, myPlugin) {
this.queue = async.queue((task, callback) => {
if(task.type==='cmd') {
this._executeDeviceAction(task.ID, task.action, task.param)
.then(result => callback(null, result))
.catch(err => callback(err, null));
.then(result => callback(null, result))

Check failure on line 34 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected parentheses around arrow function argument

Check failure on line 34 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected parentheses around arrow function argument

Check failure on line 34 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Expected parentheses around arrow function argument
.catch(err => callback(err, null));

Check failure on line 35 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Mixed spaces and tabs

Check failure on line 35 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected parentheses around arrow function argument

Check failure on line 35 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Mixed spaces and tabs

Check failure on line 35 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected parentheses around arrow function argument

Check failure on line 35 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Mixed spaces and tabs

Check failure on line 35 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Expected parentheses around arrow function argument
} else if(task.type==='scenario') {
this._executeScenarioAction(task.ID, task.action)
.then(result => callback(null, result))
.catch(err => callback(err, null));
.then(result => callback(null, result))

Check failure on line 38 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected parentheses around arrow function argument

Check failure on line 38 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected parentheses around arrow function argument

Check failure on line 38 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Expected parentheses around arrow function argument
.catch(err => callback(err, null));

Check failure on line 39 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Mixed spaces and tabs

Check failure on line 39 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected parentheses around arrow function argument

Check failure on line 39 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Mixed spaces and tabs

Check failure on line 39 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected parentheses around arrow function argument

Check failure on line 39 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Mixed spaces and tabs

Check failure on line 39 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Expected parentheses around arrow function argument
}
}, 1);
}
Expand Down Expand Up @@ -232,12 +233,13 @@ JeedomClient.prototype.updateModelInfo = function(ID,value,internal=false) {
};

JeedomClient.prototype.executeDeviceAction = function(ID, action, param) {
return new Promise((resolve, reject) => {
this.queue.push({ID, action, param, type:'cmd'}, (err, result) => {
if (err) reject(err);
else resolve(result);
});
});
if(!USE_QUEUES) return this._executeDeviceAction(ID, action, param);

Check failure on line 236 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected { after 'if' condition

Check failure on line 236 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected { after 'if' condition

Check failure on line 236 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Expected { after 'if' condition
return new Promise((resolve, reject) => {
this.queue.push({ID, action, param, type:'cmd'}, (err, result) => {
if (err) reject(err);

Check failure on line 239 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected { after 'if' condition

Check failure on line 239 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected { after 'if' condition

Check failure on line 239 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Expected { after 'if' condition
else resolve(result);

Check failure on line 240 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected { after 'else'

Check failure on line 240 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected { after 'else'

Check failure on line 240 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Expected { after 'else'
});
});
};

JeedomClient.prototype._executeDeviceAction = function(ID, action, param) {
Expand Down Expand Up @@ -278,12 +280,13 @@ JeedomClient.prototype._executeDeviceAction = function(ID, action, param) {
};

JeedomClient.prototype.executeScenarioAction = function(ID, action) {
return new Promise((resolve, reject) => {
this.queue.push({ID, action, type:'scenario'}, (err, result) => {
if (err) reject(err);
else resolve(result);
});
});
if(!USE_QUEUES) return this._executeScenarioAction(ID, action);

Check failure on line 283 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected { after 'if' condition

Check failure on line 283 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Expected { after 'if' condition

Check failure on line 283 in lib/jeedom-api.js

View workflow job for this annotation

GitHub Actions / build (21.x)

Expected { after 'if' condition
return new Promise((resolve, reject) => {
this.queue.push({ID, action, type:'scenario'}, (err, result) => {
if (err) reject(err);
else resolve(result);
});
});
};

JeedomClient.prototype._executeScenarioAction = function(ID, action) {
Expand Down

0 comments on commit 88cd069

Please sign in to comment.