forked from philsniff/com.groups
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
35 lines (33 loc) · 965 Bytes
/
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
const Homey = require('homey');
module.exports = [
{
// Get a list of all devices.
method : 'GET',
path : '/devices',
fn : async (args) => {
let devices = await Homey.app.getDevices();
return Object.values(devices);
}
},
{
// Get the library helper
method : 'GET',
path : '/library',
fn : async (args) => {
return await Homey.app.library.getJSON();
}
},
{
// We cant save the settings using await api.devices.setDeviceSettings({id: args.params.id, settings: args.body});
// As the SDK doesnt have this scope to the webAPI.
method : 'PUT',
path : '/settings/:driver',
fn : async (args) => {
let group = await Homey.ManagerDrivers.getDriver(args.params.driver).getDevice(args.body.data);
let result = await group.setSettings(args.body.settings);
console.log('calling refresh');
await group.refresh();
return result;
}
}
]