fixes
This commit is contained in:
parent
cd05021a30
commit
7dff251217
@ -15,15 +15,20 @@ var busEmitter = new EventEmitter();
|
||||
var db_name = 'mqtt';
|
||||
//var dbCouch = nano.use(db_name);
|
||||
|
||||
var globalMode = 'FanOff';
|
||||
|
||||
busEmitter.on('send', function (mode) {
|
||||
var url = ['https://maker.ifttt.com/trigger/', mode, '/with/key/cWvECkeiyAPwmiOPBkXL2D'].join('');
|
||||
|
||||
if (globalMode !== mode)
|
||||
{
|
||||
globalMode = mode;
|
||||
request(url, function (error, response, body) {
|
||||
if (!error && response.statusCode === 200) {
|
||||
console.log(body);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var mqttClient = function () {
|
||||
@ -36,7 +41,7 @@ var mqttClient = function () {
|
||||
temp: 0,
|
||||
last: 0
|
||||
};
|
||||
var mode = 'FanOff';
|
||||
var mode = 'FanOff';
|
||||
|
||||
|
||||
var d = new Date();
|
||||
@ -49,7 +54,7 @@ var mqttClient = function () {
|
||||
|
||||
// var
|
||||
|
||||
if (mode === 'FanOff') {
|
||||
if (globalMode === 'FanOff') {
|
||||
console.log('Fans off, temp should be <= 19.5');
|
||||
mode = (parseFloat(this.livingRoom.temp) <= 19.5) ? 'FanOn' : 'FanOff';
|
||||
} else {
|
||||
@ -101,9 +106,11 @@ var mqttClient = function () {
|
||||
logger.debug(json);
|
||||
logger.debug(json.temp);
|
||||
|
||||
logger.debug('GlobalMode',globalMode);
|
||||
this.livingRoom.temp = parseFloat(json.temp);
|
||||
|
||||
if (this.livingRoom.temp >= 23) {
|
||||
console.log('lr:',this.livingRoom.temp, this.livingRoom.temp >= 22.6);
|
||||
if (this.livingRoom.temp >= 22.6) {
|
||||
console.log('Max temp reached, turn off' );
|
||||
busEmitter.emit('send', 'FanOff');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user