This commit is contained in:
Martin Donnelly 2016-11-16 22:15:26 +00:00
parent 7dff251217
commit ecac472f35

View File

@ -16,18 +16,24 @@ var db_name = 'mqtt';
//var dbCouch = nano.use(db_name);
var globalMode = 'FanOff';
var lastDispatch = 0;
busEmitter.on('send', function (mode) {
var url = ['https://maker.ifttt.com/trigger/', mode, '/with/key/cWvECkeiyAPwmiOPBkXL2D'].join('');
if (globalMode !== mode)
if (mode !== globalMode)
{
globalMode = mode;
globalMode = mode;
request(url, function (error, response, body) {
if (!error && response.statusCode === 200) {
console.log(body);
}
});
var d = new Date();
lastDispatch = d.getTime();
} else {
console.log('Not sent...');
}
});
@ -69,6 +75,7 @@ var mqttClient = function () {
if (n >= 600000) {
console.error('No message received for over 10 minutes');
mode = 'FanOff';
throw new error('Ejecting for restart');
}
logger.info('LR temp:', this.livingRoom.temp);
@ -110,9 +117,9 @@ logger.debug('GlobalMode',globalMode);
this.livingRoom.temp = parseFloat(json.temp);
console.log('lr:',this.livingRoom.temp, this.livingRoom.temp >= 22.6);
if (this.livingRoom.temp >= 22.6) {
if (this.livingRoom.temp >= 23) {
console.log('Max temp reached, turn off' );
busEmitter.emit('send', 'FanOff');
busEmitter.emit('send', 'FanOff');
}
var d = new Date();
this.lastMsg = d.getTime();