-
Notifications
You must be signed in to change notification settings - Fork 1
/
flux.js
34 lines (34 loc) · 889 Bytes
/
flux.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
var WebSocketClient = require('websocket').client;
var config = require('./config.json');
const Influx = require('influx')
const influx = new Influx.InfluxDB({
host: config['influxdb']['host'],
database: 'erabliere',
schema: [
{
measurement: 'flow_rate',
fields: {
device: Influx.FieldType.STRING,
rate: Influx.FieldType.INTEGER
},
tags: [
'pump'
]
}
]
})
var dashboard = require('./dashboard.js').Dashboard(config, WebSocketClient);
dashboard.init().then(function() {
console.log('Initialized.');
return dashboard.connect().then(function() {
console.log('Connected. Starting...');
dashboard.start();
return dashboard.update();
});
}).catch(function(err) {
console.error("Error stating dashboard: ", err.stack);
});
dashboard.onChange(function() {
// Push to InfluxDB
});
console.log('Running.');