2 Copyright 2013,2014 IBM Corp.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
17 <script type="text/x-red" data-template-name="mqtt in">
18 <div class="form-row">
19 <label for="node-input-broker"><i class="fa fa-globe"></i> Broker</label>
20 <input type="text" id="node-input-broker">
22 <div class="form-row">
23 <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
24 <input type="text" id="node-input-topic" placeholder="Topic">
26 <div class="form-row">
27 <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
28 <input type="text" id="node-input-name" placeholder="Name">
32 <script type="text/x-red" data-help-name="mqtt in">
33 <p>MQTT input node. Connects to a broker and subscribes to the specified topic. The topic may contain MQTT wildcards.</p>
34 <p>Outputs an object called <b>msg</b> containing <b>msg.topic, msg.payload, msg.qos</b> and <b>msg.retain</b>.</p>
35 <p><b>msg.payload</b> is a String.</p>
38 <script type="text/javascript">
39 RED.nodes.registerType('mqtt in',{
43 topic: {value:"",required:true},
44 broker: {type:"mqtt-broker", required:true}
51 return this.name||this.topic||"mqtt";
53 labelStyle: function() {
54 return this.name?"node_label_italic":"";
59 <script type="text/x-red" data-template-name="mqtt out">
60 <div class="form-row">
61 <label for="node-input-broker"><i class="fa fa-globe"></i> Broker</label>
62 <input type="text" id="node-input-broker">
64 <div class="form-row">
65 <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
66 <input type="text" id="node-input-topic" placeholder="Topic">
68 <div class="form-row">
69 <label for="node-input-qos"><i class="fa fa-empire"></i> QoS</label>
70 <select id="node-input-qos" style="width:125px !important">
71 <option value=""></option>
72 <option value="0">0</option>
73 <option value="1">1</option>
74 <option value="2">2</option>
76 <i class="fa fa-history"></i> Retain <select id="node-input-retain" style="width:125px !important">
77 <option value=""></option>
78 <option value="false">false</option>
79 <option value="true">true</option>
82 <div class="form-row">
83 <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
84 <input type="text" id="node-input-name" placeholder="Name">
86 <div class="form-tips">Tip: Leave topic, qos or retain blank if you want to set them via msg properties.</div>
89 <script type="text/x-red" data-help-name="mqtt out">
90 <p>Connects to a MQTT broker and publishes <b>msg.payload</b> either to the <b>msg.topic</b> or to the topic specified in the edit window. The value in the edit window has precedence.</p>
91 <p>Likewise QoS and/or retain values in the edit panel will overwrite any <b>msg.qos</b> and <b>msg.retain</b> properties. If nothing is set they default to <i>0</i> and <i>false</i> respectively.</p>
92 <p>If <b>msg.payload</b> contains an object it will be stringified before being sent.</p>
95 <script type="text/javascript">
96 RED.nodes.registerType('mqtt out',{
103 broker: {type:"mqtt-broker", required:true}
111 return this.name||this.topic||"mqtt";
113 labelStyle: function() {
114 return this.name?"node_label_italic":"";
119 <script type="text/x-red" data-template-name="mqtt-broker">
120 <div class="form-row node-input-broker">
121 <label for="node-config-input-broker"><i class="fa fa-globe"></i> Broker</label>
122 <input class="input-append-left" type="text" id="node-config-input-broker" placeholder="localhost" style="width: 40%;" >
123 <label for="node-config-input-port" style="margin-left: 10px; width: 35px; "> Port</label>
124 <input type="text" id="node-config-input-port" placeholder="Port" style="width:45px">
126 <div class="form-row">
127 <label for="node-config-input-clientid"><i class="fa fa-tag"></i> Client ID</label>
128 <input type="text" id="node-config-input-clientid" placeholder="Leave blank for auto generated">
130 <div class="form-row">
131 <label for="node-config-input-user"><i class="fa fa-user"></i> Username</label>
132 <input type="text" id="node-config-input-user">
134 <div class="form-row">
135 <label for="node-config-input-password"><i class="fa fa-lock"></i> Password</label>
136 <input type="password" id="node-config-input-password">
140 <script type="text/javascript">
141 RED.nodes.registerType('mqtt-broker',{
144 broker: {value:"",required:true},
145 port: {value:1883,required:true,validate:RED.validators.number()},
146 clientid: { value:"" }
150 password: {type: "password"}
153 if (this.broker == "") { this.broker = "localhost"; }
154 return (this.clientid?this.clientid+"@":"")+this.broker+":"+this.port;