UNPKG

node-red-contrib-blynk-iot

Version:
95 lines (89 loc) 3.26 kB
<script type="text/javascript"> // eslint-disable-next-line func-names (function () { function onEditSave() { } function onEditPrepare() { } function label() { if (this.metaname !== '' && this.action !== 'bycode') return `${this.action} - ${this.metaname}`; if (this.metaname !== '') return this.metaname; return 'by code'; } RED.nodes.registerType('blynk-iot-metadata', { category: 'Blynk IoT', paletteLabel: 'metadata', defaults: { name: { value: '' }, metaname: { value: '' }, action: { value: 'bycode', required: true }, client: { type: 'blynk-iot-client', required: true }, }, color: '#8be8c8', inputs: 1, outputs: 1, icon: 'font-awesome/fa-tags', align: 'right', labelStyle() { return this.name ? 'node_label_italic' : ''; }, label, oneditsave: onEditSave, oneditprepare: onEditPrepare, }); }()); </script> <!-- Blynk out Node - Write --> <script type="text/x-red" data-template-name="blynk-iot-metadata"> <div class="form-row" id="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" id="div-write-action"> <label for="node-input-action"><i class="fa fa-play-circle-o"></i> <span>Action</span></label> <select id="node-input-action" style="width:70%"> <option value="bycode" >By code</option> <option value="get" >Get</option> <option value="set" >Set</option> </select> </div> <div class="form-row"> <label for="node-input-metaname"><i class="fa fa-tags"></i> <span>Metadata</span></label> <input type="text" id="node-input-metaname"> </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-iot-metadata"> <p>Blynk metadata node.</p> <p>For use with Blynk app metadata Widget in merge mode.</p> <p>To select the color you can use the following methods:<p> <p>Set <code>msg.hex</code> with hex notation color. (ex. <code>#ff0000</code> for red)<br/> Set <code>msg.r</code> <code>msg.g</code> <code>msg.b</code> with the relative integer value. (ex. <code>msg.r = 255; msg.g = 0; msg.b = 0; </code> for red)<br/> Set <code>msg.payload</code> to string with rgb values separated by semicolons or "\0". (ex. <code>255;0;0</code> for red)<br/> </p> <p><b>This node also captures write events!</b></p> <p>Example output:<br> <pre> <code>{ "payload":[ 0, 178, 77 ], "pin":"0", "hex":"#00b24d", "r":0, "g":178, "b":77, "rgb":"0;178;77" }</code> </pre> <p> <p class="form-tips"> Official documentation: <a href="https://docs.blynk.io/en/blynk.edgent-firmware-api/metadata">metadata</a> <p> </script>