node-red-contrib-blynk-ws
Version:
Node Red integration with Blynk App and Server through websockets
94 lines (87 loc) • 3.15 kB
HTML
<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 onEditSave() {
}
function onEditPrepare() {
}
function label() {
const type = 'zeRGBa';
const pin = (validPin(this.pin)) ? `Pin V${this.pin} - ${type}` : 'pin error';
return this.name || pin;
}
RED.nodes.registerType('blynk-ws-zergba', {
category: 'Blynk_ws',
paletteLabel: 'zergba',
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',
inputs: 1,
outputs: 1,
icon: 'zergba.png',
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-ws-zergba">
<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" id="div-write-pin">
<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-zergba">
<p>Blynk zeRGBa node.</p>
<p>For use with Blynk app zeRGBa 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://gablau.dev/blynk-legacy-docs/#widgets-controllers-zergba">zeRGBa</a>
<p>
</script>