some changes to global mode

This commit is contained in:
Martin Donnelly 2017-02-28 22:31:04 +00:00
parent 0f31666c57
commit 0a56812189
2 changed files with 13 additions and 1 deletions

View File

@ -47,7 +47,7 @@ const mqttClient = function(events) {
if (mode !== globalMode) {
logger.info('Go for change state');
globalMode = mode;
// globalMode = mode;
logger.debug('Global Mode now A:', globalMode);
/* Request(url, function (error, response, body) {
logger.debug(response, body);
@ -159,6 +159,10 @@ const mqttClient = function(events) {
this.client.subscribe('livingroomTemp');
this.client.on('updateState', function(newStatus) {
globalMode = (newStatus === 0) ? 'FanOff' : 'FanOn';
});
this.client.on('message', function(topic, message) {
const now = new Date;
const nowMS = (now.getHours() * 3600000) + (now.getMinutes() * 60000);

View File

@ -55,12 +55,20 @@ busEmitter.on('changeState', function(mode) {
if (wemoClient !== null) {
wemoClient.setBinaryState(mode);
let newState = wemoClient.getBinaryState();
busEmitter.emit('updateState', newState);
} else {
console.error('No wemoClient');
}
});
setInterval(function() {
let newState = wemoClient.getBinaryState();
busEmitter.emit('updateState', newState);
}, 30000);
let mqtt = new mqttClient.mqttClient(busEmitter);