Repository navigation
Expand file tree
/
Copy pathapi.js
More file actions
52 lines (48 loc) · 1.46 KB
/
Copy pathapi.js
File metadata and controls
52 lines (48 loc) · 1.46 KB
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
/*jslint node: true */
module.exports = {
async getLog( { homey, query } )
{
return homey.app.getFormattedDiagLog();
},
async getDetect( { homey, query } )
{
if ( !homey.app.hasApiAccess() )
{
return {
error: 'No SmartThings authentication available. Pair or repair the device again.',
authenticated: false,
devices: homey.app.detectedDevices || null,
};
}
// Keep this endpoint non-blocking for the settings UI. Any background
// fetch failures are swallowed to prevent unhandled rejections/crashes.
homey.app.getDevices( true ).catch( () => null );
return {
authenticated: true,
devices: homey.app.detectedDevices || null,
};
},
async clearLog( { homey, body } )
{
homey.app.diagLog = "";
return homey.app.getFormattedDiagLog();
},
async sendCmd( { homey, body } )
{
var result = await homey.app.GetURL( body.command );
if ( result )
{
let searchData = JSON.parse( result.body );
return searchData;
}
throw new Error( "No Response" );
},
async SendDeviceLog({ homey, body })
{
return homey.app.sendLog('deviceLog', body.email, body.description);
},
async SendInfoLog({ homey, body })
{
return homey.app.sendLog('infoLog', body.email, body.description);
},
};