Storing msg.payload in select tag

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

I think you will find this question has been answered in the last few days. Yes, you can create a dropdown using a select tag. You need to use the oneditprepare function to set it up and manage it.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.