-
Notifications
You must be signed in to change notification settings - Fork 10
/
api.js
50 lines (49 loc) · 1.21 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
const Homey = require('homey');
module.exports = [
{
// Get all groups.
method : 'GET',
path : '/group',
fn : async (args) => {
let groups = await Homey.app.getGroups();
return groups.map(group => ({
id : group.getData().id,
name : group.getName(),
class : group.getClass(),
}));
}
},
{
// Get a specific group.
method : 'GET',
path : '/group/:id',
fn : async (args) => {
let group = await Homey.app.getGroup(args.params.id);
return {
id : args.params.id,
name : group.getName(),
class : group.getClass(),
capabilities : group.getCapabilities(),
data : group.getData(),
settings : group.getSettings(),
};
}
},
{
// Update the grouped devices for a group.
method : 'PUT',
path : '/group/:id',
fn : async (args) => {
await Homey.app.setDevicesForGroup(args.params.id, args.body);
}
},
{
// Get a list of all devices.
method : 'GET',
path : '/devices',
fn : async (args) => {
let devices = await Homey.app.getDevices();
return Object.values(devices);
}
},
]