forked from Patrikgolfer/com.uc.heimdall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.js
executable file
·41 lines (40 loc) · 1.24 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
'use strict';
const Homey = require('homey')
module.exports = [
{
description: 'Retrieve all devices with their information',
method: 'GET',
path: '/devices',
fn: function(args, callback) {
Homey.app.getDevices().then(res => {
callback(null, res);
})
.catch(error => callback(error, null));
}
},
{
description: 'Retrieve all zones with their information',
method: 'GET',
path: '/zones',
fn: function(args, callback) {
Homey.app.getZones().then(res => {
callback(null, res);
})
.catch(error => callback(error, null));
}
},
{
description: 'Request Alarm state and Surveillance Mode',
method: 'GET',
path: '/state/:type',
fn: function(args, callback) {
if (args.params.type === 'surveillance') {
callback(null, Homey.ManagerSettings.get('surveillanceStatus'));
} else if (args.params.type === 'alarm' ) {
callback(null, Homey.ManagerSettings.get('alarmStatus'));
} else {
callback("not a valid status request", null);
}
}
}
]