I'm trying to send an SNMP set command to a PDU (Power Distribution Unit), but the SNMP set node is rejecting because my varbind is not numbers.
The UI has a selection box where the user can pick the outlet they want to reboot.
The function takes that number and adds it to the first part of the OID to form the completed OID that the PDU will recognize.
The Value is also supposed to be an integer of 3 for the PDU reboot command.
In debug, the array is formed correctly, but the data types are string, which is where I'm thinking the SNMP node is rejecting.
How can I convert the OID to a number, and have the msg.varbind set keep it as a number and not convert it?
Regarding function structure;
The prior flow steps have the user select an outlet number in the UI, then an alert makes them manually re-enter the number to avoid typos or accidental reboots of the wrong equipment. The IF branch is just to verify that the same outlet selected is the outlet the user confirmed.
Once the user selects an outlet, a different function uses that selected number to form the OID and send it to the SNMP Get node, where it returns the OutletName, which is displayed on the popup for the user to confirm.
So the function to form the OID works for SNMP Get, but I'm thinking SNMP get accepts strings, while SNMP set does not.
var outlet = flow.get('SelectedOutlet');
var outletName = flow.get('OutletName');
var value = 3;
if (outlet == msg.payload){
var oidfrag = "1.3.6.1.4.1.3808.1.1.3.3.3.1.1.4";
var oid = oidfrag + "." + outlet;
msg.host = flow.get('PDU1host');
msg.community = flow.get('PDU1set');
msg.varbinds = [{"oid":""+oid+"","type":"OctetString","value":""+value.toFixed(0)+""}]
msg.payload = outletName;
return [msg, null];
}
msg.host = " ";
msg.community = " ";
msg.varbinds = " ";
msg.payload = outletName;
msg.outlet = outlet;
return [null, msg];