diff --git a/package.json b/package.json index 5095884..7aa1f58 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vvzvlad/node-red-contrib-rn-combined-nodes", - "version": "0.2.1", + "version": "0.2.2", "description": "", "main": "index.js", "keywords": [ diff --git a/thermostat-analyzer.js b/thermostat-analyzer.js index f77c44c..72ec529 100644 --- a/thermostat-analyzer.js +++ b/thermostat-analyzer.js @@ -121,16 +121,16 @@ module.exports = function(RED) { node.on('input', function(msg) { + if (msg.payload.heater_status === null && typeof msg.payload.heater_status === "undefined") msg_state_text = null + else msg_state_text = { payload: status_reason(msg) } + + if (msg.payload.current_temp === null && typeof msg.payload.current_temp === "undefined") msg_current_temp = null + else msg_state_text = { payload: get_current_temp(msg) } + let key = "fake" - let mqtt_debug = { payload: analyzer(msg), topic: `debug/${node.zone}_${node.room}_/th/${key}`} - let state_text = { payload: status_reason(msg) } - let current_temp = { payload: get_current_temp(msg) } + let msg_mqtt_debug = { payload: analyzer(msg), topic: `debug/${node.zone}_${node.room}_/th/${key}`} - if (heater_status === null || typeof heater_status === "undefined") { - msg_heater_status = null - } - - node.send([mqtt_debug, state_text, current_temp]); + node.send([msg_mqtt_debug, msg_state_text, msg_current_temp]); });