UNPKG

node-red-contrib-blynk-ws

Version:

Node Red integration with Blynk App and Server through websockets

81 lines (73 loc) 3.26 kB
<script type="text/javascript"> // eslint-disable-next-line func-names (function () { function validPin(tmppin) { const tmpPin = parseInt(tmppin, 10); if (Number.isInteger(tmpPin) && tmpPin >= 0 && tmpPin <= 255) { return true; } return false; } function onEditPrepare() { } function onEditSave() { } function label() { const type = 'Table'; const pin = (validPin(this.pin)) ? `Pin V${this.pin} - ${type}` : 'pin error'; return this.name || pin; } RED.nodes.registerType('blynk-ws-out-table', { category: 'Blynk_ws', paletteLabel: 'table', defaults: { name: { value: '' }, pin: { value: '', required: true, validate: RED.validators.regex(/^([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$/) }, client: { type: 'blynk-ws-client', required: true }, }, color: '#1BC17C', icon: 'table.png', align: 'right', inputs: 1, outputs: 0, labelStyle() { return this.name ? 'node_label_italic' : ''; }, label, oneditsave: onEditSave, oneditprepare: onEditPrepare, }); }()); </script> <!-- Blynk out Node - Table --> <script type="text/x-red" data-template-name="blynk-ws-out-table"> <div class="form-row" id="websocket-client-row"> <label for="node-input-client"><i class="fa fa-bookmark"></i> <span>Connection</span></label> <input type="text" id="node-input-client"> </div> <div class="form-row"> <label for="node-input-pin"><i class="fa fa-dot-circle-o"></i> <span>Virtual Pin</span></label> <input type="number" id="node-input-pin" min="0" max="255" placeholder="pin"> </div> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> <span>Name</span></label> <input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name"> </div> </script> <script type="text/x-red" data-help-name="blynk-ws-out-table"> <p>Blynk Table node.</p> <p>For use with Blynk app Table Widget.</p> <p>Set <code>msg.add</code> with an array of <code>['name','value']</code> to add row to the table.<br/> Set <code>msg.update</code> with an array of <code>['index','name','value']</code> to update row to the table.<br/> Set <code>msg.pick</code> to the row index you want to highlight.<br/> Set <code>msg.select</code> to the row index you want to select.<br/> Set <code>msg.deselcet</code> to the row index you want to deselect.<br/> Set <code>msg.loadtable</code> with an array of arrays <code>['name','value']</code> or <code>['name']</code> depending on how many rows you want to add to the table<br/> Set <code>msg.order</code> with an array of two values <code>['old row idx','new row idx']</code> (ex. <code>[1,4]</code> to move row index 1 to 4.)<br/> Set <code>msg.clear</code> to <code>true</code> if you want to clear all table rows. (Index is reset to 0). </p> <p class="form-tips"> Official documentation: <a href="https://gablau.dev/blynk-legacy-docs/#widgets-interface-table">Table</a> <p> </script>