UNPKG

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

100 lines (95 loc) 3.65 kB
<script type="text/javascript"> RED.nodes.registerType('mysdecode',{ category: 'mysensors', color: '#a6bbcf', defaults: { database: {value:"", type: "mysensorsdb", required: false}, name: {value:""}, mqtt: {value: false, required:true}, enrich: {value: false} }, inputs:1, outputs:1, icon: "arrow-in.png", label: function() { var type = "mysdecode serial"; if (this.mqtt) type = "mysdecode mqtt"; return this.name||type; }, inputLabels: "MQTT topic or mysensors input", outputLabels: ["decoded out"], oneditprepare: function() { if ($('#node-input-enrich').is(':checked')) { $('.databaseRow').show(); } else { $('.databaseRow').hide(); } $('#node-input-enrich').click(function() { if (this.checked) { $('.databaseRow').show(); } else { $('.databaseRow').hide(); } }); } }); </script> <script type="text/html" data-template-name="mysdecode"> <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"> <label for="node-input-enrich"><i class="fa fa-tag"></i> Use DB</label> <input type="checkbox" id="node-input-enrich"> </div> <div class="form-row databaseRow"> <label for="node-input-database"><i class="fa fa-tag"></i> Database</label> <input type="text" id="node-input-database" placeholder="Database"> </div> </script> <script type="text/html" data-help-name="mysdecode"> <p> Parses either <code>msg.payload</code> from mysensors serial format, or <code>msg.topic</code> if MQTT type is chosen </p> <p> Note! If enrich is ticked off, then each message will result in a db query to the sqlite database </p> <h3>Input</h3> <dl class="message-properties"> <dt>payload</dt> <dt>topic</dt> </dl> <h3>Output</h3> <dl class="message-properties"> <dt>nodeId <span class="property-type">number</span></dt> <dd></dd> <dt>childSensorId <span class="property-type">number</span></dt> <dd></dd> <dt>messageType <span class="property-type">number</span></dt> <dd></dd> <dt>ack <span class="property-type">0 or 1</span></dt> <dd></dd> <dt>subType <span class="property-type">number</span></dt> <dd></dd> <dt>payload <span class="property-type">string</span></dt> <dd></dd> <dt>messageTypeStr <span class="property-type">string</span></dt> <dd>String representation of the messageType</dd> <dt>subTypeStr <span class="property-type">string</span></dt> <dd>String representation of subType</dd> </dl> <h3>Details</h3> <p> By ticking off the MQTT option, this node operates on MQTT topics instead of MySensors serial protocol. </p> <p> If "use DB" is ticked, then the node will use the configured database, to retrieve extra information about sensor type etc. given by the node during presentation, and add this to each message that passes through the node. </p> </script>