forked from AdyRock/com.switchbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.js
62 lines (60 loc) · 1.17 KB
/
api.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
50
51
52
53
54
55
56
57
58
59
60
61
62
/* jslint node: true */
'use strict';
module.exports = {
async getLog({ homey, query })
{
return homey.app.diagLog;
},
async getDetect({ homey, query })
{
try
{
homey.app.detectedDevices = await homey.app.getHUBDevices();
}
catch (err)
{
if (!homey.app.detectedDevices)
{
homey.app.detectedDevices = err.message;
}
}
return homey.app.detectedDevices;
},
async clearLog({ homey, query })
{
homey.app.diagLog = '';
return 'OK';
},
async SendDeviceLog({ homey, query })
{
return homey.app.sendLog('deviceLog');
},
async SendInfoLog({ homey, query })
{
return homey.app.sendLog('infoLog');
},
async SendStatusLog({ homey, query })
{
return homey.app.sendLog('statusLog');
},
async clearStatusLog({ homey, query })
{
homey.app.deviceStatusLog = '';
return 'OK';
},
async newData({ homey, body })
{
if (homey.app.BLEHub)
{
homey.app.BLEHub.newBLEHubData(body);
}
return 'OK';
},
async requestDeviceStatus({ homey, query })
{
const retval = await homey.app.getDeviceStatus(query.deviceId);
const data = JSON.stringify(retval, null, 2);
homey.app.deviceStatusLog += data;
return homey.app.deviceStatusLog;
},
};