forked from swttt/com.swttt.homekit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
52 lines (51 loc) · 1.05 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
'use strict';
const Homey = require('homey')
module.exports = [
{
method : 'GET',
path : '/devices',
fn : async (args, callback) => {
try {
return callback(null, await Homey.app.getDevices());
} catch(err) {
return callback(err);
}
}
},
{
method : 'PUT',
path : '/devices/:id',
fn : async (args, callback) => {
try {
await Homey.app.addDeviceById(args.params.id);
return callback();
} catch(err) {
return callback(err);
}
}
},
{
method : 'DELETE',
path : '/devices/:id',
fn : async (args, callback) => {
try {
Homey.app.deleteDeviceById(args.params.id);
return callback();
} catch(err) {
return callback(err);
}
}
},
{
method : 'GET',
path : '/clear-storage',
fn : async (args, callback) => {
try {
Homey.app.clearStorage();
return callback(null, { value : true });
} catch(err) {
return callback(err);
}
}
},
];