removed CTDO-API
This commit is contained in:
parent
f6610cf7a2
commit
782d4a1a35
22
ctdo-api.js
22
ctdo-api.js
|
@ -1,22 +0,0 @@
|
||||||
var util = require('util');
|
|
||||||
var EventEmitter = require('events').EventEmitter;
|
|
||||||
var request = require('request');
|
|
||||||
|
|
||||||
var CTDOApi= function(url) {
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.poll = function() {
|
|
||||||
request({url: "https://" + url}, function(error, res, response) {
|
|
||||||
if (error) {
|
|
||||||
self.emit('failed', error)
|
|
||||||
} else {
|
|
||||||
var parsedResponse = JSON.parse(response);
|
|
||||||
|
|
||||||
self.emit('done', parsedResponse);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
util.inherits(CTDOApi, EventEmitter);
|
|
||||||
module.exports = CTDOApi;
|
|
16
statusbot.js
16
statusbot.js
|
@ -8,7 +8,6 @@ var cookieSession = require('cookie-session');
|
||||||
var flash = require('connect-flash');
|
var flash = require('connect-flash');
|
||||||
var Flukso = require("./flukso");
|
var Flukso = require("./flukso");
|
||||||
var IpPoll = require("./ip-poll");
|
var IpPoll = require("./ip-poll");
|
||||||
var CTDOApi = require("./ctdo-api");
|
|
||||||
var routes = require("./routes");
|
var routes = require("./routes");
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var mqttClient = require('mqtt');
|
var mqttClient = require('mqtt');
|
||||||
|
@ -74,7 +73,6 @@ var usercountanswer = {
|
||||||
};
|
};
|
||||||
|
|
||||||
var ippoll = new IpPoll("rpi3.raum.ctdo.de");
|
var ippoll = new IpPoll("rpi3.raum.ctdo.de");
|
||||||
var ctdoapi = new CTDOApi("api.ctdo.de/names.php");
|
|
||||||
var flukso = new Flukso("flukso.raum.ctdo.de", "/sensor/cf00e0b22230f4a8870af58f2b8719dd");
|
var flukso = new Flukso("flukso.raum.ctdo.de", "/sensor/cf00e0b22230f4a8870af58f2b8719dd");
|
||||||
var mqtt = mqttClient.connect('mqtt://raum.ctdo.de');
|
var mqtt = mqttClient.connect('mqtt://raum.ctdo.de');
|
||||||
var connected = false;
|
var connected = false;
|
||||||
|
@ -82,19 +80,6 @@ var connected = false;
|
||||||
var port = '9911';
|
var port = '9911';
|
||||||
var address = 'localhost';
|
var address = 'localhost';
|
||||||
|
|
||||||
ctdoapi.on('done', function (answer) {
|
|
||||||
simpleanswer.count = answer.count;
|
|
||||||
simpleanswer.names = answer.names;
|
|
||||||
|
|
||||||
spaceanswer.sensors.people_now_present[0].value = answer.count;
|
|
||||||
spaceanswer.sensors.people_now_present[0].names = answer.names;
|
|
||||||
|
|
||||||
if (usercountanswer.datapoints.length > 20) {
|
|
||||||
usercountanswer.datapoints.shift();
|
|
||||||
}
|
|
||||||
|
|
||||||
usercountanswer.datapoints.push({at: new Date().getTime(), value: simpleanswer.count});
|
|
||||||
});
|
|
||||||
|
|
||||||
ippoll.on('doneState', function (state) {
|
ippoll.on('doneState', function (state) {
|
||||||
spaceanswer.state.open = state;
|
spaceanswer.state.open = state;
|
||||||
|
@ -131,7 +116,6 @@ function sendSimple() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function work() {
|
function work() {
|
||||||
ctdoapi.poll();
|
|
||||||
ippoll.pollState();
|
ippoll.pollState();
|
||||||
sendSimple();
|
sendSimple();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue