some changes to global mode
This commit is contained in:
parent
0f31666c57
commit
0a56812189
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user