node-red-contrib-mysensors
Version:
Mysensors related nodes, for decoding / encoding mysensors serial protocol and MQTT topic, and wrapping arbitrary messages into mysensors compatible messages
102 lines (95 loc) • 3.76 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('mysencode',{
category: 'mysensors',
color: '#a6bbcf',
defaults: {
name: {value: ""},
mqtt: {value: false, required:true},
mqtttopic: {value: ""}
},
inputs:1,
outputs:1,
icon: "arrow-in.png",
label: function() {
var type = "mysencode serial";
if (this.mqtt) {
type = "mysencode mqtt";
if (this.mqtttopic) {
type = type + " " + this.mqtttopic;
}
}
return this.name || type;
},
inputLabels: "Message input",
outputLabels: ["MQTT / Mysensors output"],
align:"right",
oneditprepare: function() {
if ($('#node-input-mqtt').is(':checked')) {
$('#node-input-row-mqtttopic').show();
} else {
$('#node-input-row-mqtttopic').hide();
}
$('#node-input-mqtt').click(function() {
if (this.checked) {
$('#node-input-row-mqtttopic').show();
} else {
$('#node-input-row-mqtttopic').hide();
}
});
}
});
</script>
<script type="text/html" data-template-name="mysencode">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-mqtt"><i class="fa fa-tag"></i> MQTT</label>
<input type="checkbox" id="node-input-mqtt">
</div>
<div class="form-row" id="node-input-row-mqtttopic">
<label for="node-input-mqtttopic"><i class="fa fa-tag"></i> Topic root</label>
<input type="text" id="node-input-mqtttopic" placeholder="topic">
</div>
</script>
<script type="text/html" data-help-name="mysencode">
<p>
Encodes messages into mysensors serial / mqtt topic compatible messages, that can be sent to either a gateway,
or a controller that understands mysensors serial protocol or mqtt topic format.
</p>
<h3>Input</h3>
<dl class="message-properties">
<dt>nodeId <span class="property-type">number</span></dt>
<dd>Required</dd>
<dt>childSensorId <span class="property-type">number</span></dt>
<dd>Required</dd>
<dt>messageType <span class="property-type">number</span></dt>
<dd>Required</dd>
<dt>ack <span class="property-type">0 or 1</span></dt>
<dd>Required</dd>
<dt>subType <span class="property-type">number</span></dt>
<dd>Required</dd>
<dt>payload <span class="property-type">string</span></dt>
<dd>Optional</dd>
<dt>topicRoot <span class="property-type">string</span></dt>
<dd>Optional</dd>
</dl>
<h3>Output - MQTT</h3>
<dl class="message-properties">
<dt>topic <span class="property-type">string</span></dt>
<dd>topic configured as topicRoot/nodeId/childSensorId/messageType/ack/subType</dd>
<dt>payload <span class="property-type">string</span></dt>
<dd>left untouched</dd>
</dl>
<h3>Output - Serial</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>nodeId;childSensorId;messageType;ack;subType;payload</dd>
</dl>
<h3>Details</h3>
<p>
By checking off the MQTT option, this node create a MQTT topic, compatible with mysensors, instead of MySensors serial protocol.
Setting Topic root overwrites incomming msg.topicRoot for MQTT mode.
<p>
</script>