-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode_helper.js
43 lines (38 loc) · 1.1 KB
/
node_helper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* Magic Mirror
* Node Helper: MMM-Binance
*
* By: Thomas Samai
*
*/
var NodeHelper = require("node_helper");
const Binance = require('node-binance-api');
const binance = new Binance().options({
APIKEY: config.API_TOKEN,
APISECRET: config.SECRET_API_KEY
});
module.exports = NodeHelper.create({
start: function() {
console.log("Starting node_helper for: " + this.name);
var self = this;
this.getData();
},
getData: function() {
var self = this
let myPromise = new Promise(function(myResolve, myReject) {
binance.balance(function(error, balances) {
myResolve(balances);
});
});
myPromise.then(
function(value) {
balanceData = value;
},
function(error) {myReject(error)}
)
},
socketNotificationReceived: function(notification, payload) {
if (notification === 'open-socket') {
this.sendSocketNotification("balance-payload", balanceData)
}
}
});