forked from mnederlof/com.ubnt.unifi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
40 lines (32 loc) · 1.03 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
"use strict";
const Homey = require('homey');
module.exports = [
{
method: 'GET',
path: '/sites',
fn: function( args, callback ){
let driver = Homey.ManagerDrivers.getDriver('wifi-client');
let _default_list = [{'name': 'default', 'desc': 'default'}];
if (!driver.unifi) {
Homey.app.initSettings();
return callback(null, _default_list);
}
driver.unifi.get('/api/self/sites')
.then(res => {
callback( null, res.data );
})
.catch(err => {
callback( err, _default_list)
});
}
},
{
method: 'PUT',
path: '/settings',
fn: function( args, callback ){
var result = Homey.app.updateSettings( args.body );
if( result instanceof Error ) return callback( result );
return callback( null, result );
}
},
]