I want to select pin value from the HTML radio button as a msg.payloadand and pass it in to rpio.open(pin, rpio.OUTPUT, rpio.LOW);
in my HTML file
<script type="text/javascript">
RED.nodes.registerType('muxbox-pins-out',{
category: 'MUXBOX',
color: '#C0C0C0',
defaults: {
name: {value: ""},
pin: { value:"", required:true, validate:RED.validators.number() },
},
inputs:1, //1
outputs:0,//0
icon: "font-awesome/fa-cogs",
label: function() {
return this.name||"muxbox-pins-out";
},
outputLabels: function() { return "GPIO"+this.pin; },
oneditprepare: function() {
$('#pinform input').on('change', function() {
this.pin = $("#pinform input[type='radio']:checked").val();
$("#node-input-pin").val(this.pin);
});
}
});
</script>
<script type="text/html" data-template-name="muxbox-pins-out">
<div class="form-row" style="min-width: 540px">
<label><i class="fa fa-circle"></i>PIN OUT<span data-i18n="rpi-gpio.pin"></span></label>
<input type="text" id="node-input-pin" style="display:none;">
<div class="rpi-gpio-pinTable">
<div class="pinTableBody" id="pinform">
<div class="pinTableRow">
<div class="pinTableCellL pinColorDual"><label for="pinTable-pin-1">DO1 - GPIO6 - 1 <input id="pinTable-pin-1" type="radio" name="pins" value="1"></label></div>
<div class="pinTableCellR pinColorPower"><label><input disabled type="radio" name="pins" value=""> 2 - 24V Power</label></div>
</div>
<div class="pinTableRow">
<div class="pinTableCellL pinColorDual"><label for="pinTable-pin-2">DO2 - GPIO12 - 3 <input id="pinTable-pin-2" type="radio" name="pins" value="2"></label></div>
<div class="pinTableCellR pinColorPower"><label><input disabled type="radio" name="pins" value=""> 4 - 24V Power</label></div>
</div>
<div class="pinTableRow">
<div class="pinTableCellL pinColorDual"><label for="pinTable-pin-5">DO3 - GPIO13 - 5 <input id="pinTable-pin-5" type="radio" name="pins" value="5"></label></div>
<div class="pinTableCellR pinColorPower"><label><input disabled type="radio" name="pins" value=""> 6 - 24V Power</label></div>
</div>
<div class="pinTableRow">
<div class="pinTableCellL pinColorDual"><label for="pinTable-pin-5">DO4 - GPIO19 - 7 <input id="pinTable-pin-5" type="radio" name="pins" value="5"></label></div>
<div class="pinTableCellR pinColorPower"><label><input disabled type="radio" name="pins" value=""> 6 - 24V Power</label></div>
</div>
<div class="pinTableRow">
<div class="pinTableCellL pinColorDual"><label for="pinTable-pin-5">DO5 - GPIO5 - 9 <input id="pinTable-pin-5" type="radio" name="pins" value="5"></label></div>
<div class="pinTableCellR pinColorPower"><label><input disabled type="radio" name="pins" value=""> 10 - 24V Power</label></div>
</div>
<div class="pinTableRow">
<div class="pinTableCellL pinColorDual"><label for="pinTable-pin-5">DO6 - GPIO16 - 11 <input id="pinTable-pin-5" type="radio" name="pins" value="5"></label></div>
<div class="pinTableCellR pinColorPower"><label><input disabled type="radio" name="pins" value=""> 12 - 24V Power</label></div>
</div>
</div>
</div>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
</script>
in my js file
module.exports = function(RED) {
"use strict";
const rpio = require('rpio');
function muxBoxPins(config) {
RED.nodes.createNode(this,config);
var node = this;
node.on('input', function(msg) {
const pin = Number(msg.payload)
rpio.open(pin, rpio.OUTPUT, rpio.LOW);
rpio.write(pin, rpio.HIGH);
node.send(msg);
});
}
RED.nodes.registerType("muxbox-pins",muxBoxPins);
}