forked from koktaildotcom/com.p1.smartmeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.js
33 lines (28 loc) · 851 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
const Homey = require('homey');
module.exports = [
{
method: 'POST',
path: '/update',
public: true,
fn: function (args, callback) {
if (args.hasOwnProperty('body')) {
Homey.emit('update.data', args.body);
callback(null, 'OK');
}
return callback( new Error('Cannot find body.') );
},
},
{
method: 'POST',
path: '/update/dsmrreader',
public: true,
fn: function (args, callback) {
if (args.hasOwnProperty('body')) {
const DsmrReader = Homey.app.dsmrreader;
Homey.emit('update.data', DsmrReader.parseData(args.body));
callback(null, 'OK');
}
return callback( new Error('Cannot find body.') );
},
},
];