UNPKG

ncd-red-industrial

Version:

70 lines (67 loc) 2.24 kB
<script type="text/javascript"> RED.nodes.registerType('ncd-proxr',{ category: 'NCD', color: '#a6bbcf', defaults: { name: {value: ""}, connection: {value:"", type: "ncd-comm-ind"}, }, inputs:1, outputs:1, icon: "serial.png", label: function() { return this.name || "ProXR"; }, oneditprepare: function() { $('#node-input-encryptKey').keyup(function(){ var val = $(this).val(); if(!val.length) return; var parts = val.replace(/-/g, '').match(/.{1,2}/g); if(parts.length > $('#node-input-encryptBits').val()){ parts.pop(); } $(this).val(parts.join('-')); }); } }); </script> <script type="text/x-red" data-template-name="ncd-proxr"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input id="node-input-name" /> </div> <div class="form-row"> <label for="node-input-connection"><i class="icon-tag"></i> Connection</label> <select id="node-input-connection"></select> </div> </script> <script type="text/x-red" data-help-name="ncd-proxr"> <h3>ProXR Commands</h3> <p>This node allows you to send ProXR commands over a serial or TCP connection, using either an object or a human-readable string.</p> <h5>String commands</h5> <p> To use a string, simply send in what you would like to do to the node i.e:<br/> "turn on relay 1"<br/> "pulse relay 2 in 1 minute"<br/> "turn on relay 3 on bank 2 for 30 seconds"<br/> "toggle relay 4"<br/> <i>For the time being, numeric values must be numeric (2 NOT two)</i>. </p> <h5>Object commands</h5> <p> When sending an object (JSON) the topic of the message must be "json", the value depends on the actiion you are trying to take, the structure is illustrated below. </p> <pre><code> var command = { relay: (int) 1-1024, group: (string) all, even, or odd, banks: (bool) all banks, bank: (int) 1-128, get: (bool) get status of bank and/or relay op: (string) on, off, active, deactivate, toggle, mtype: (string) in (pulse *in* x) or for (on *for* x), duration: (int|obj) {h,m,s}, scale: (string) second(s), minute(s), or hour(s) optional if duration is obj } </code></pre> </script>