diff --git a/nodes/core/io/10-mqtt.html b/nodes/core/io/10-mqtt.html index b42eff2fc..65674f6bc 100644 --- a/nodes/core/io/10-mqtt.html +++ b/nodes/core/io/10-mqtt.html @@ -20,6 +20,14 @@ +
+ + +
@@ -44,6 +52,7 @@ defaults: { name: {value:""}, topic: {value:"",required:true,validate: RED.validators.regex(/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/)}, + qos: {value: "2"}, broker: {type:"mqtt-broker", required:true} }, color:"#d8bfd8", @@ -55,6 +64,11 @@ }, labelStyle: function() { return this.name?"node_label_italic":""; + }, + oneditprepare: function() { + if (this.qos === undefined) { + $("#node-input-qos").val("2"); + } } }); diff --git a/nodes/core/io/10-mqtt.js b/nodes/core/io/10-mqtt.js index 2cc4ee9f3..fe663737b 100644 --- a/nodes/core/io/10-mqtt.js +++ b/nodes/core/io/10-mqtt.js @@ -298,6 +298,8 @@ 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.broker = n.broker; this.brokerConn = RED.nodes.getNode(this.broker); if (!/^(#$|(\+|[^+#]*)(\/(\+|[^+#]*))*(\/(\+|#|[^+#]*))?$)/.test(this.topic)) { @@ -308,7 +310,7 @@ module.exports = function(RED) { this.status({fill:"red",shape:"ring",text:"common.status.disconnected"}); if (this.topic) { node.brokerConn.register(this); - this.brokerConn.subscribe(this.topic,2,function(topic,payload,packet) { + this.brokerConn.subscribe(this.topic,this.qos,function(topic,payload,packet) { if (isUtf8(payload)) { payload = payload.toString(); } var msg = {topic:topic,payload:payload, qos: packet.qos, retain: packet.retain}; if ((node.brokerConn.broker === "localhost")||(node.brokerConn.broker === "127.0.0.1")) {