From 2b9bfbc3095173d231ff57c91adb33e6cc4889ef Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 20 Jun 2016 21:35:43 +0100 Subject: [PATCH] MQTT In subscription qos not defaulting properly --- nodes/core/io/10-mqtt.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nodes/core/io/10-mqtt.js b/nodes/core/io/10-mqtt.js index 365cdf099..791571e56 100644 --- a/nodes/core/io/10-mqtt.js +++ b/nodes/core/io/10-mqtt.js @@ -314,8 +314,10 @@ module.exports = function(RED) { function MQTTInNode(n) { RED.nodes.createNode(this,n); this.topic = n.topic; - this.qos = parseInt(n.qos===undefined?"2":n.qos); - + this.qos = parseInt(n.qos); + if (isNaN(this.qos) || this.qos < 0 || this.qos > 2) { + this.qos = 2; + } this.broker = n.broker; this.brokerConn = RED.nodes.getNode(this.broker); if (!/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/.test(this.topic)) {