This is how I would do it.
[{"id":"7bf7bca7.cb2724","type":"function","z":"caebef34.4abf3","name":"","func":"var key_str = \"NODE, DIR,SPEED,PRESS, RH, TEMP, DEWPOINT,PRT,AN1,AN2,DIG1,VOLT, STATUS\";\nvar keys = key_str.split(\",\");\n\nvar values = msg.payload.split(\",\");\n\nvar i;\nfor (i = 0; i < values.length; i++) {\n msg[keys[i]] = values[i];\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":480,"wires":[["8a153fb6.efdcc","f271e113.5bc7e"]]},{"id":"fffcd4d2.f6e258","type":"inject","z":"caebef34.4abf3","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":" Q,014,000.06,1011.2,042.1,+023.0,+009.4,,#,#,#,+04.9,00, 40","payloadType":"str","x":250,"y":480,"wires":[["7bf7bca7.cb2724"]]},{"id":"8a153fb6.efdcc","type":"debug","z":"caebef34.4abf3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":590,"y":480,"wires":[]},{"id":"f271e113.5bc7e","type":"ha-entity","z":"caebef34.4abf3","name":"weather","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[{"property":"dir","value":"DIR","valueType":"msg"},{"property":"speed","value":"SPEED","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","x":630,"y":420,"wires":[[]]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
I haven’t installed the component below that is why there is an error.
Function node code:
var key_str = "NODE, DIR,SPEED,PRESS, RH, TEMP, DEWPOINT,PRT,AN1,AN2,DIG1,VOLT, STATUS";
var keys = key_str.split(",");
var values = msg.payload.split(",");
var i;
for (i = 0; i < values.length; i++) {
msg[keys[i]] = values[i];
}
return msg;
Using: Custom Component for node-red-contrib-home-assistant-websocket