forked from robertklep/name.klep.sonoff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
34 lines (33 loc) · 817 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
const Homey = require('homey');
module.exports = [
{
method : 'GET',
path : '/rf-devices/',
fn : async (args, callback) => {
try {
let devices = await Homey.app.apiListRfDevices();
return callback(null, devices.map(device => ({
id : device.getData().id,
name : device.getName(),
})));
} catch(err) {
return callback(err);
}
}
},
{
method : 'GET',
path : '/tasmota-devices/',
fn : async (args, callback) => {
try {
let devices = await Homey.app.apiListTasmotaDevices();
return callback(null, devices.map(device => ({
id : device.getData().id,
name : device.getName(),
})));
} catch(err) {
return callback(err);
}
}
},
];