bus system proper
This commit is contained in:
parent
81f0222ff6
commit
a8b3f4da6c
@ -4,6 +4,7 @@ var util = require('util');
|
||||
var logger = require('log4js').getLogger();
|
||||
|
||||
var EventEmitter = require('events');
|
||||
var Minibus = require('minibus');
|
||||
|
||||
// var db = require('../server/db-connector').dbConnection;
|
||||
|
||||
@ -14,9 +15,8 @@ var busEmitter = new EventEmitter();
|
||||
var db_name = 'mqtt';
|
||||
//var dbCouch = nano.use(db_name);
|
||||
|
||||
var bus = Minibus.create();
|
||||
|
||||
bus.on('send', function (mode) {
|
||||
busEmitter.on('send', function (mode) {
|
||||
var url = ['https://maker.ifttt.com/trigger/', mode, '/with/key/cWvECkeiyAPwmiOPBkXL2D'].join('');
|
||||
|
||||
request(url, function (error, response, body) {
|
||||
@ -68,7 +68,7 @@ var mqttClient = function () {
|
||||
|
||||
logger.info('LR temp:', this.livingRoom.temp);
|
||||
|
||||
bus.emit('send', mode);
|
||||
busEmitter.emit('send', mode);
|
||||
|
||||
setTimeout(this.fanTimer.bind(this), mod + 10);
|
||||
};
|
||||
@ -104,7 +104,7 @@ var mqttClient = function () {
|
||||
this.livingRoom.temp = parseFloat(json.temp);
|
||||
|
||||
if (this.livingRoom.temp >= 23) {
|
||||
bus.emit('send', 'FanOff');
|
||||
busEmitter.emit('send', 'FanOff');
|
||||
}
|
||||
var d = new Date();
|
||||
this.lastMsg = d.getTime();
|
||||
|
Loading…
Reference in New Issue
Block a user