Hi all,
I have a problem which I just cannot understand and therefore, haven't managed to solve. I'm pretty new to Node Red but have done programming in the past
I am reading data in from a serial connection to my Solar Tubes water heating store. Data comes once per minute. I am looking to extract the temperature readings for the Top, Middle and Bottom of the storage tank
The stream comes in as follows:
2021-04-03 13:03:40;52;27;37;50;17;35;7;1;1;0;5;1;22;18136;32767;EU;2;TR0603mc;Err;1;0;; ending in a CR (0xa)
So I wrote a simple first function
msg.payload = msg.payload.split(';');
msg.payload = "Top:" + msg.payload[4] + ",Middle:" + msg.payload[3] + ",Bottom:" + msg.payload[2];
return msg;
which gives me the new array string "Top:xx,Middle:xx,Bottom:xx". I then use the SPLIT node, splitting on a Comma, and a Fixed Length of 1, and then sending it into a SWITCH with 3 options created using contains Top, Middle or Bottom.
The problem is that the output is correct the first time around, but then goes haywire - see the Debug window
Here again is some more of the debug
4/4/2021, 1:29:04 PM[node: Whole Array](http://192.168.1.4:1880/#)msg.payload : string[26]
"Top:56,Middle:54,Bottom:39"
4/4/2021, 1:29:04 PM[node: Top](http://192.168.1.4:1880/#)msg.payload : string[15]
"Bottom:39Top:56"
4/4/2021, 1:29:05 PM[node: Bottom](http://192.168.1.4:1880/#)msg.payload : string[15]
"Bottom:39Top:56"
4/4/2021, 1:29:06 PM[node: Middle](http://192.168.1.4:1880/#)msg.payload : string[9]
"Middle:54"
4/4/2021, 1:30:04 PM[node: Whole Array](http://192.168.1.4:1880/#)msg.payload : string[26]
"Top:56,Middle:54,Bottom:39"
4/4/2021, 1:30:04 PM[node: Top](http://192.168.1.4:1880/#)msg.payload : string[15]
"Bottom:39Top:56"
4/4/2021, 1:30:05 PM[node: Bottom](http://192.168.1.4:1880/#)msg.payload : string[15]
"Bottom:39Top:56"
4/4/2021, 1:30:06 PM[node: Middle](http://192.168.1.4:1880/#)msg.payload : string[9]
"Middle:54"