forked from ysimonx/node-red-contrib-melcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
49 lines (38 loc) · 1.65 KB
/
test.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
44
45
46
47
48
49
const { SlowBuffer } = require('buffer');
var https = require('https'),
urllib = require("url");
const { Melcloud } = require("./melcloud.js");
function main() {
var melcloud = new Melcloud("****","****");
melcloud.getContext()
.then(
() => {
melcloud.getListDevices()
.then(async list => {
for (var j=0; j < list.payload.length; j++) {
var devices = list.payload[j].Structure.Devices;
for(var i=0; i< devices.length;i++) {
await melcloud.getDeviceInfo( devices[i].DeviceID, devices[i].BuildingID)
.then(device => {
console.log(devices[j]);
console.log(device);
// console.log(melcloud.context);
}).catch(err => {
console.error(err);
return;
});
}
}
}
).catch(err => {
console.error(err);
return;
})
}
)
.catch(err => {
console.error(err.error);
return;
});
}
main();