Skip to content

Commit

Permalink
Update mqtt-rules.js
Browse files Browse the repository at this point in the history
  • Loading branch information
terafin committed May 30, 2023
1 parent 4eec95a commit 0522fce
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions mqtt-rules.js
Expand Up @@ -140,22 +140,23 @@ const connectionProcessor = function() {

// need to capture everything that comes in, and process it as such
const changedTopics = Object.keys(collectedMQTTTChanges)

changedTopics.forEach(topic => {
const message = collectedMQTTTChanges[topic]

global.generateContext(topic, message, function(outTopic, outMessage, context) {
if (_.isNil(outTopic) || _.isNil(outMessage)) {
logging.error(' *** NOT Processing rules for: ' + topic)
logging.error(' outTopic: ' + outTopic)
logging.error(' outMessage: ' + outMessage)
} else {
context['firstRun'] = true
global.changeProcessor(null, context, outTopic, outMessage)
}

if ( !_.isNil(changedTopics) ) {
changedTopics.forEach(topic => {
const message = collectedMQTTTChanges[topic]

global.generateContext(topic, message, function(outTopic, outMessage, context) {
if (_.isNil(outTopic) || _.isNil(outMessage)) {
logging.error(' *** NOT Processing rules for: ' + topic)
logging.error(' outTopic: ' + outTopic)
logging.error(' outMessage: ' + outMessage)
} else {
context['firstRun'] = true
global.changeProcessor(null, context, outTopic, outMessage)
}
})
})
})

}
stopCollectingMQTTChanges()
logging.info(' => Done!')
}
Expand Down Expand Up @@ -940,4 +941,4 @@ if (utilities.testMode() == false) {
rule_loader.load_path(config_path)
} else {
logging.debug('not - loading rules')
}
}

0 comments on commit 0522fce

Please sign in to comment.