"TypeError: Cannot read property 'toString' of undefined"

Hi all.
I noticed a day or so ago, I have stopped getting some values. The error is "TypeError: Cannot read property 'toString' of undefined"
and it comes from my 32bit Modbus converters, I have pasted the 32 bit code and complete flow, byt I cant understand why it would just start to do this?
Any recomendations please?
Thank You

[{"id":"66778f6e.e6ec1","type":"function","z":"6d01e3e4.6003b4","name":"Flow 1 32bit register coversion /100","func":"var low = msg.payload[0];\nvar high = msg.payload[1];\n\nvar lowhex = low.toString(16);\nvar highhex = high.toString(16);\n\nvar total = ((high << 16) + low) / 100;\n\nmsg.payload = total;\nmsg.measurement = \"W\";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1340,"y":220,"wires":[["a9b4a1bf.e78"]]}]
[{"id":"6d01e3e4.6003b4","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"54ad2798.4a3dc8","type":"function","z":"6d01e3e4.6003b4","name":"FC 4 Add_3100 (18)","func":"msg.payload = { \n    'fc': 4, \n    'unitid': 2, \n    'address': 0x3100, \n    'quantity': 18\n}\n\nmsg.topic = \"livestats\";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":180,"y":100,"wires":[["2fd5cbe9.42df14"]]},{"id":"5b319361.03f7c4","type":"inject","z":"6d01e3e4.6003b4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":"10","topic":"","payload":"1","payloadType":"str","x":90,"y":40,"wires":[["54ad2798.4a3dc8","371ad8d2.5eb44"]]},{"id":"2fd5cbe9.42df14","type":"modbus-flex-getter","z":"6d01e3e4.6003b4","name":"","showStatusActivities":false,"showErrors":false,"logIOActivities":false,"server":"f659adbe.b499a8","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"keepMsgProperties":false,"x":320,"y":160,"wires":[["6f2e521b.edc75c","12e028f6.20238f"],[]]},{"id":"6f2e521b.edc75c","type":"split","z":"6d01e3e4.6003b4","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":530,"y":120,"wires":[["5ced9593.c888dc"]]},{"id":"5ced9593.c888dc","type":"switch","z":"6d01e3e4.6003b4","name":"","property":"parts.index","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"2","vt":"str"},{"t":"eq","v":"3","vt":"str"},{"t":"eq","v":"4","vt":"str"},{"t":"eq","v":"5","vt":"str"},{"t":"eq","v":"6","vt":"str"},{"t":"eq","v":"7","vt":"str"},{"t":"eq","v":"8","vt":"str"},{"t":"eq","v":"9","vt":"str"},{"t":"eq","v":"E","vt":"str"},{"t":"eq","v":"F","vt":"str"},{"t":"eq","v":"12","vt":"str"},{"t":"eq","v":"13","vt":"str"},{"t":"eq","v":"14","vt":"str"},{"t":"eq","v":"15","vt":"str"},{"t":"eq","v":"16","vt":"str"},{"t":"eq","v":"17","vt":"str"},{"t":"eq","v":"","vt":"str"}],"checkall":"false","repair":false,"outputs":19,"x":690,"y":200,"wires":[["9286c5ac.8ecef"],["74fc517a.019128"],["f1d30f65.9c5a9"],["f1d30f65.9c5a9"],["35e35209.66106e"],["2400e4f3.6337a4"],["5acffb8.e1a6684"],["5acffb8.e1a6684"],["23d4d5eb.1426c2"],["f144bf25.c8005"],["6c7f8e0.3a3eef4"],["6c7f8e0.3a3eef4"],[],[],[],[],["d4d0aaa5.cc087"],["939ae148.f384c"],[]]},{"id":"9286c5ac.8ecef","type":"change","z":"6d01e3e4.6003b4","name":"SolarVoltage","rules":[{"t":"set","p":"topic","pt":"msg","to":"SolarVoltage","tot":"str"},{"t":"set","p":"SolarVoltage","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":40,"wires":[["1b866af4.cff2b5"]]},{"id":"74fc517a.019128","type":"change","z":"6d01e3e4.6003b4","name":"SolarCurrant","rules":[{"t":"set","p":"topic","pt":"msg","to":"SolarCurrant","tot":"str"},{"t":"set","p":"SolarCurrant","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":80,"wires":[["783feece.2885b"]]},{"id":"1b866af4.cff2b5","type":"range","z":"6d01e3e4.6003b4","minin":"1","maxin":"10000","minout":"1","maxout":"100","action":"scale","round":true,"property":"payload","name":"SV/100","x":1080,"y":20,"wires":[["678d22fc.6eaaac","54431f19.42f86"]]},{"id":"783feece.2885b","type":"range","z":"6d01e3e4.6003b4","minin":"1","maxin":"10000","minout":"1","maxout":"100","action":"scale","round":true,"property":"payload","name":"SC/100","x":1080,"y":60,"wires":[["fe7c8d55.107198","c97502.f0c513"]]},{"id":"678d22fc.6eaaac","type":"ui_text","z":"6d01e3e4.6003b4","group":"3bf43a81.2b807e","order":2,"width":0,"height":0,"name":"SolarVoltage","label":"Solar Voltage (V)","format":"{{msg.payload}}","layout":"col-center","x":1270,"y":20,"wires":[]},{"id":"fe7c8d55.107198","type":"ui_text","z":"6d01e3e4.6003b4","group":"3bf43a81.2b807e","order":1,"width":0,"height":0,"name":"SolarCurrant","label":"Solar Currant (A)","format":"{{msg.payload}}","layout":"col-center","x":1270,"y":60,"wires":[]},{"id":"f1d30f65.9c5a9","type":"join","z":"6d01e3e4.6003b4","name":"SolarPower","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":890,"y":120,"wires":[["946f29ac.37a58"]]},{"id":"946f29ac.37a58","type":"change","z":"6d01e3e4.6003b4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"SolarPower","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":120,"wires":[["66778f6e.e6ec1"]]},{"id":"66778f6e.e6ec1","type":"function","z":"6d01e3e4.6003b4","name":"Flow 1 32bit register coversion /100","func":"var low = msg.payload[0];\nvar high = msg.payload[1];\n\nvar lowhex = low.toString(16);\nvar highhex = high.toString(16);\n\nvar total = ((high << 16) + low) / 100;\n\nmsg.payload = total;\nmsg.measurement = \"W\";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1340,"y":220,"wires":[["a9b4a1bf.e78"]]},{"id":"a9b4a1bf.e78","type":"switch","z":"6d01e3e4.6003b4","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"SolarPower","vt":"str"},{"t":"eq","v":"BatteryPower","vt":"str"},{"t":"eq","v":"LoadPower","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":1570,"y":220,"wires":[["350c1dd9.3d7e8a"],["ca329322.eb2c38"],["5528f5b1.036f94"]]},{"id":"350c1dd9.3d7e8a","type":"ui_text","z":"6d01e3e4.6003b4","group":"3bf43a81.2b807e","order":3,"width":0,"height":0,"name":"SolarPower","label":"Solar Power (W)","format":"{{msg.payload}}","layout":"col-center","x":1790,"y":160,"wires":[]},{"id":"35e35209.66106e","type":"change","z":"6d01e3e4.6003b4","name":"BatteryVoltage","rules":[{"t":"set","p":"topic","pt":"msg","to":"BatteryVoltage","tot":"str"},{"t":"set","p":"BatteryVoltage","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":180,"wires":[["d87c92a8.750778"]]},{"id":"d87c92a8.750778","type":"range","z":"6d01e3e4.6003b4","minin":"1","maxin":"10000","minout":"1","maxout":"100","action":"scale","round":false,"property":"payload","name":"BV/100","x":1080,"y":200,"wires":[["6ad2d3e3.faa86c","a9c0b836.75f0e"]]},{"id":"6ad2d3e3.faa86c","type":"ui_text","z":"6d01e3e4.6003b4","group":"92374fdb.9d242","order":2,"width":5,"height":1,"name":"BatteryVoltage","label":"Battery Voltage (V)","format":"{{msg.payload}}","layout":"col-center","x":1200,"y":260,"wires":[]},{"id":"2400e4f3.6337a4","type":"change","z":"6d01e3e4.6003b4","name":"BatteryCurrant","rules":[{"t":"set","p":"topic","pt":"msg","to":"BatteryCurrant","tot":"str"},{"t":"set","p":"BatteryCurrant","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":220,"wires":[["83f3494.3223e38"]]},{"id":"83f3494.3223e38","type":"range","z":"6d01e3e4.6003b4","minin":"1","maxin":"10000","minout":"1","maxout":"100","action":"scale","round":true,"property":"payload","name":"BC/100","x":1060,"y":300,"wires":[["dcc280d9.d2cbb"]]},{"id":"dcc280d9.d2cbb","type":"ui_text","z":"6d01e3e4.6003b4","group":"92374fdb.9d242","order":1,"width":5,"height":1,"name":"BatteryCurrant","label":"Battery Currant (A)","format":"{{msg.payload}}","layout":"col-center","x":1300,"y":340,"wires":[]},{"id":"5acffb8.e1a6684","type":"join","z":"6d01e3e4.6003b4","name":"BatteryPower","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":920,"y":340,"wires":[["e7031e7d.34ee18"]]},{"id":"e7031e7d.34ee18","type":"change","z":"6d01e3e4.6003b4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"BatteryPower","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1110,"y":380,"wires":[["66778f6e.e6ec1"]]},{"id":"ca329322.eb2c38","type":"ui_text","z":"6d01e3e4.6003b4","group":"92374fdb.9d242","order":5,"width":5,"height":1,"name":"BatteryPower","label":"Battery Power (W)","format":"{{msg.payload}}","layout":"col-center","x":1760,"y":220,"wires":[]},{"id":"23d4d5eb.1426c2","type":"change","z":"6d01e3e4.6003b4","name":"LoadVoltage","rules":[{"t":"set","p":"topic","pt":"msg","to":"LoadVoltage","tot":"str"},{"t":"set","p":"LoadVoltage","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":500,"wires":[["aa9a45bd.2b69a8"]]},{"id":"aa9a45bd.2b69a8","type":"range","z":"6d01e3e4.6003b4","minin":"1","maxin":"10000","minout":"1","maxout":"100","action":"scale","round":true,"property":"payload","name":"LV/100","x":1070,"y":480,"wires":[["7fd887d8.0baf9"]]},{"id":"7fd887d8.0baf9","type":"ui_text","z":"6d01e3e4.6003b4","group":"d0e60a67.4d8d6","order":2,"width":5,"height":1,"name":"LoadVoltage","label":"Load Voltage (V)","format":"{{msg.payload}}","layout":"col-center","x":1270,"y":480,"wires":[]},{"id":"f144bf25.c8005","type":"change","z":"6d01e3e4.6003b4","name":"LoadCurrant","rules":[{"t":"set","p":"topic","pt":"msg","to":"LoadCurrant","tot":"str"},{"t":"set","p":"LoadCurrant","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":580,"wires":[["e19bc326.872e28"]]},{"id":"e19bc326.872e28","type":"range","z":"6d01e3e4.6003b4","minin":"1","maxin":"10000","minout":"1","maxout":"100","action":"scale","round":true,"property":"payload","name":"LC/100","x":1080,"y":560,"wires":[["83e20cc7.c538e8"]]},{"id":"83e20cc7.c538e8","type":"ui_text","z":"6d01e3e4.6003b4","group":"d0e60a67.4d8d6","order":1,"width":5,"height":1,"name":"LoadCurrant","label":"Load Currant (A)","format":"{{msg.payload}}","layout":"col-center","x":1270,"y":560,"wires":[]},{"id":"6c7f8e0.3a3eef4","type":"join","z":"6d01e3e4.6003b4","name":"LoadPower","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":830,"y":660,"wires":[["797cb612.7f17d8"]]},{"id":"797cb612.7f17d8","type":"change","z":"6d01e3e4.6003b4","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"LoadPower","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1090,"y":700,"wires":[["66778f6e.e6ec1"]]},{"id":"5528f5b1.036f94","type":"ui_text","z":"6d01e3e4.6003b4","group":"d0e60a67.4d8d6","order":3,"width":5,"height":1,"name":"LoadPower","label":"Load Power (W)","format":"{{msg.payload}}","layout":"col-center","x":1770,"y":300,"wires":[]},{"id":"9c402cb3.84a3c8","type":"ui_text","z":"6d01e3e4.6003b4","group":"92374fdb.9d242","order":6,"width":5,"height":1,"name":"BatteryTemperature","label":"Battery Temp. (°C)","format":"{{msg.payload}}","layout":"col-center","x":1090,"y":780,"wires":[]},{"id":"d4d0aaa5.cc087","type":"change","z":"6d01e3e4.6003b4","name":"BatteryTemperature","rules":[{"t":"set","p":"topic","pt":"msg","to":"BatteryTemperature","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":740,"wires":[["33678140.b256be"]]},{"id":"33678140.b256be","type":"range","z":"6d01e3e4.6003b4","minin":"0","maxin":"10000","minout":"0","maxout":"100","action":"scale","round":true,"property":"payload","name":"BT/100","x":840,"y":760,"wires":[["9c402cb3.84a3c8"]]},{"id":"fdfe2815.147488","type":"ui_text","z":"6d01e3e4.6003b4","group":"9d0d030a.31d","order":1,"width":5,"height":1,"name":"CaseTemperature","label":"Device Temp. (°C)","format":"{{msg.payload}}","layout":"col-center","x":1070,"y":820,"wires":[]},{"id":"939ae148.f384c","type":"change","z":"6d01e3e4.6003b4","name":"CaseTemperature","rules":[{"t":"set","p":"topic","pt":"msg","to":"CaseTemperature","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":780,"wires":[["2d74da1b.726566"]]},{"id":"2d74da1b.726566","type":"range","z":"6d01e3e4.6003b4","minin":"0","maxin":"10000","minout":"0","maxout":"100","action":"scale","round":true,"property":"payload","name":"CT/100","x":840,"y":840,"wires":[["fdfe2815.147488"]]},{"id":"371ad8d2.5eb44","type":"link out","z":"6d01e3e4.6003b4","name":"","links":["2424ebbe.20330c","1a8e330.633f3cd","eed8fc15.cd5658"],"x":280,"y":40,"wires":[]},{"id":"54431f19.42f86","type":"influxdb out","z":"6d01e3e4.6003b4","influxdb":"94401065.fe856","name":"","measurement":"SolarVoltage","precision":"","retentionPolicy":"","x":1540,"y":20,"wires":[]},{"id":"c97502.f0c513","type":"influxdb out","z":"6d01e3e4.6003b4","influxdb":"94401065.fe856","name":"","measurement":"SolarCurrant","precision":"","retentionPolicy":"","x":1540,"y":60,"wires":[]},{"id":"a9c0b836.75f0e","type":"influxdb out","z":"6d01e3e4.6003b4","influxdb":"94401065.fe856","name":"","measurement":"BatteryVoltage","precision":"","retentionPolicy":"","x":1570,"y":400,"wires":[]},{"id":"12e028f6.20238f","type":"modbus-response","z":"6d01e3e4.6003b4","name":"3100 Response","registerShowMax":20,"x":490,"y":340,"wires":[]},{"id":"f659adbe.b499a8","type":"modbus-client","name":"TracerA12","clienttype":"serial","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":false,"tcpHost":"192.168.4.25","tcpPort":"23","tcpType":"TELNET","serialPort":"/dev/ttyUSB0","serialType":"RTU-BUFFERD","serialBaudrate":"115200","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"2","commandDelay":"100","clientTimeout":"2000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":false},{"id":"3bf43a81.2b807e","type":"ui_group","name":"Solar Information","tab":"28c10730.74ad38","order":1,"disp":true,"width":5,"collapse":true},{"id":"92374fdb.9d242","type":"ui_group","name":"Battery Information","tab":"28c10730.74ad38","order":2,"disp":true,"width":5,"collapse":false},{"id":"d0e60a67.4d8d6","type":"ui_group","name":"DC Load Information","tab":"28c10730.74ad38","order":3,"disp":true,"width":5,"collapse":false},{"id":"9d0d030a.31d","type":"ui_group","name":"Controller Information","tab":"28c10730.74ad38","order":4,"disp":true,"width":5,"collapse":false},{"id":"94401065.fe856","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"Solar","name":"Grafana","usetls":false,"tls":"","influxdbVersion":"1.x"},{"id":"28c10730.74ad38","type":"ui_tab","name":"Solar PV Equipment","icon":"dashboard","disabled":false,"hidden":false}]

Add a debug node showing what is going into the node generating the error and make sure all the data you expect is in the message.

I have added that, but it does not seem to get any information from the Function Mod

If I put the debug on the Set Message Topic, before the 32bit converter I can see two undefines, then the values coming in

Put a debug node on each of the nodes feeding the function nodes
Also the debug of the solar power shows some undefined...why? You need to look at them so add some debug nodes,to each node feeding that flow path to see why the data Is undefined

I put three debugs 1 on Solar Voltage, 1 on Solar Current, 1 on SolarPower and 1 on the set msg.topic from Solar Power.
It has the undefines which I an guessing are the top two coming from the switch which are solar voltage and solar current. I think!!!!

Don't guess, you need to know. If you hover over the id number above the debug output it will highlight the node the message comes from. Even better give your debug nodes names and then it will show the name in the debug pane.

I am pretty confident the issue is coming from the Join Node as the first two values are undefined, then I get the actual values

Yep, The Undefined is coming from the Join Node. If I map the top two values from the switch to the join, so I have 0,1,2,3 from the switch to the Join, the 32 Bit converter has no error's, now this is producing the wrong in, as I want the H and L for the Solar Power from 2 and 3 on the switch. As can be seen its creating an Array of 4, but I just want two values!
Found the issue, not the solution!
Cheers

Why do you now have four (4) inputs to the join node?

That was just a test to see the values, I did have it using two inputs but then the first two come as undefined, so why does the join see 4 values, two undefined and two real?

What settings do you have in the join?
Also what is in the change node?

Just this, unless there is another way of editing the Join Mod
Thanks

I would put a debug node (set to display the complete msg object and with unique names) on the two outputs of the switch feeding the join node to see what data is being joined.

Your join will join everything that gets to it in 1 second.

The output from the switch seems to be only sending a value from each output.
Switch Output 3 is getting values like 10317and Switch Output 4 gets a value of 0
If I put the debug on the Join it shows the array of 4, of which the first 2 are undefined, which is what is causing my issue. Why would a Join create an array of 4 when only 2 are being used?

Look at your join settings and the documentation. You have set a timeout of one second and so it will join all msgs that arrive till the timeout is reached. You could get one msg or 30 joined depending on the speed they arrive.

It works correctly with the same settings using a test

This also seems weird.
If I put a JOIN on the first output from a switch, it creates an array of [1] and displays a value

If I then remove the first join link and put a JOIN on the second output from a switch, it creates an array of [2] with only one connection and displays undefined and a value

If I then remove the second join link and put a JOIN on the third output from a switch, it creates an array of [3] with only one connection and displays two undefined and a value

and it just goes on, and on

Put a debug on the switch to see what it sends to the join

Did that and it sends the correct info

Looks like the switch is getting the array from the modbus getter