This is my custom websocket node. As you see the msg it outputs is an object
{ name: datapointname, value: data }
Could i somehow create Select tag that has options based on how many msg.payload it recives. Options text would be the datapointname
property and the value would be data
property
module.exports = function(RED) {
function wsListenerNode(config) {
RED.nodes.createNode(this,config);
this.path = config.path;
var node = this;
node.on('input', function(msg) {
const WebSocket = require ("ws") // Require Websocket
let path = node.path;
let ws = new WebSocket(path); //Connect to the WebSocket //ws://192.168.1.41:22080/webevent/
ws.onopen = (e) => {
console.log(e);
setTimeout(function () {
ws.send(
msg.payload
);
}, 1000);
};
ws.onmessage = (e) => {
msg.payload = e.data;
var stripped = msg.payload.trim();
var values = stripped.split("\n");
var datapointname = values[0].substring(37, values[0].length - 14);
data = Number(values[1]);
msg.payload = {name:datapointname,value: data}
node.send(msg)
};
});
}
RED.nodes.registerType("websocketListener",wsListenerNode);
}
I want to display the result when i open the node