diff --git a/node/notification.js b/node/notification.js index 25b8ef4..ed515a2 100644 --- a/node/notification.js +++ b/node/notification.js @@ -1,8 +1,11 @@ var notifier = require('node-notifier'); +var path = require('path'); -var Notification = function (currentstate) { +var Notification = function () { - this.notificate = function () { + var laststate = false; + + this.notificate = function (currentstate) { notifier.on('click', function (notifierObject, options) { // Happens if `wait: true` and user clicks notification @@ -12,8 +15,8 @@ var Notification = function (currentstate) { // Happens if `wait: true` and notification closes }); - if (currentstate == true && laststate != true) { - laststate == true; + if (currentstate === true && laststate != true) { + laststate = true; notifier.notify({ title: 'CTDO - Status', message: 'Der Chaostreff Dortmund ist nun offen.', @@ -25,7 +28,7 @@ var Notification = function (currentstate) { }); //console.log("State changed to Open"); } else if (currentstate == false && laststate != false) { - laststate == false; + laststate = false; notifier.notify({ title: 'CTDO - Status', message: 'Der Chaostreff Dortmund ist nun geschlossen.', @@ -37,18 +40,8 @@ var Notification = function (currentstate) { }); //console.log("State changed to Close"); } + //console.log("Currentstate: " + currentstate + " Laststate: " + laststate); }; }; module.exports = Notification; - - - - - - - - - - - diff --git a/node/statusbot.js b/node/statusbot.js index c006dd4..89af0b5 100644 --- a/node/statusbot.js +++ b/node/statusbot.js @@ -59,7 +59,7 @@ var usercountanswer = {at: 0, current_value: 0, datapoints: [ var snmpMac = new SnmpMac("juni.ctdo.de", "ctdo23"); var ippoll = new IpPoll("switch2.raum.ctdo.de", "195.160.169.30-120"); var flukso = new Flukso("flukso.raum.ctdo.de", "/sensor/cf00e0b22230f4a8870af58f2b8719dd"); -var notification = new Notification(spaceanswer.state.open) +var notification = new Notification(); snmpMac.on('done', function (res) { simpleanswer.names = res; @@ -93,7 +93,7 @@ io.configure(function () { function work() { snmpMac.poll(); ippoll.pollCount(); - notification.notificate(spaceanswer.state.open); + notification.notificate(simpleanswer.state); } setInterval(work, 60000);