From 9fbe822c338d2cb17b8eaa3642345bee6907fe51 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Tue, 28 Feb 2017 22:34:35 +0000 Subject: [PATCH] some changes to global mode --- lib/mqtt/mqttClient.js | 1 + server.js | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/mqtt/mqttClient.js b/lib/mqtt/mqttClient.js index 749da95..a54549b 100644 --- a/lib/mqtt/mqttClient.js +++ b/lib/mqtt/mqttClient.js @@ -161,6 +161,7 @@ const mqttClient = function(events) { this.client.on('updateState', function(newStatus) { globalMode = (newStatus === 0) ? 'FanOff' : 'FanOn'; + logger.info('updateState changed to: ', globalMode); }); this.client.on('message', function(topic, message) { diff --git a/server.js b/server.js index 818aea8..e768049 100644 --- a/server.js +++ b/server.js @@ -44,6 +44,7 @@ wemo.discover(function(deviceInfo) { // Handle BinaryState events wemoClient.on('binaryState', function(value) { logger.debug('Binary State changed to: %s', value); + busEmitter.emit('updateState', value); }); // Turn the switch on @@ -55,8 +56,8 @@ busEmitter.on('changeState', function(mode) { if (wemoClient !== null) { wemoClient.setBinaryState(mode); - let newState = wemoClient.getBinaryState(); - busEmitter.emit('updateState', newState); + // let newState = wemoClient.getBinaryState(); + // busEmitter.emit('updateState', newState); } else { console.error('No wemoClient'); }