Compare commits

...

2 Commits

Author SHA1 Message Date
Lucas Pleß 0082d4932b feat: added environment variables for configuration
continuous-integration/drone Build is passing Details
feat: added SIGINT event for CTRL+C support
2022-10-18 17:18:49 +02:00
Lucas Pleß d8e93ed525 feat: added environment variables for configuration 2022-10-12 08:48:30 +02:00
2 changed files with 19 additions and 6 deletions

View File

@ -23,6 +23,13 @@ Fionera fügte HTML5 Push notifications hinzu.
Danach kleinere Änderungen und Erweiterungen von henne, zeus, smash.
## config via environment variablen
PING_INTERVAL_MS default 60000
MQTT_SERVER default 'mqtt://mqtt.ctdo.de
FLUKSO_URL default "/sensor/cf00e0b22230f4a8870af58f2b8719dd
FLUKSO_HOST default"flukso.raum.ctdo.de"
STATUS_POLL_HOST default "snapserv.ctdo.de"
## Entrümpelung 2022
@ -30,7 +37,7 @@ Danach kleinere Änderungen und Erweiterungen von henne, zeus, smash.
Das meiste an Funktionn wurde wiede raus geworfen weil sich die CTDO infrastruktur
sehr verändert hat und einiges kaputt war.
Der Status zeit nur noch Power und Raumstatus an. Es läuft wie gehabt via nmap-Ping.
Der Status zeigt nur noch Power und Raumstatus an. Es läuft wie gehabt via ICMP Ping.

View File

@ -8,6 +8,7 @@ var IpPoll = require("./ip-poll");
var routes = require("./routes");
var path = require('path');
var mqttClient = require('mqtt');
var process = require('process')
var spaceanswer = {
api: "0.13",
@ -63,15 +64,20 @@ var spaceanswer = {
var simpleanswer = {state: "unknown", lastchange: 0, power: 0};
var ippoll = new IpPoll("rpi3.raum.ctdo.de");
var flukso = new Flukso("flukso.raum.ctdo.de", "/sensor/cf00e0b22230f4a8870af58f2b8719dd");
var mqtt = mqttClient.connect('mqtt://raum.ctdo.de');
var ippoll = new IpPoll(process.env.STATUS_POLL_HOST || "snapserv.ctdo.de");
var flukso = new Flukso(process.env.FLUKSO_HOST || "flukso.raum.ctdo.de",
process.env.FLUKSO_URL || "/sensor/cf00e0b22230f4a8870af58f2b8719dd");
var mqtt = mqttClient.connect(process.env.MQTT_SERVER || 'mqtt://mqtt.ctdo.de');
var connected = false;
//express js settings
var port = '9911';
var port = process.env.HTTP_PORT || '9911';
var address = '0.0.0.0';
process.on('SIGINT', () => {
console.info("Interrupted")
process.exit(0)
})
ippoll.on('doneState', function (state) {
spaceanswer.state.open = state;
@ -113,7 +119,7 @@ function work() {
sendSimple();
}
setInterval(work, 60000);
setInterval(work, process.env.PING_INTERVAL_MS || 60000);
work();
setInterval(flukso.pollPower, 5000);