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

**URL:** <https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064>\
**Category:** General\
**Created:** [22 May 2021 05:12 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064 "2021-05-22T05:12:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![swanside](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/swanside/32/28781_2.png) [@swanside](https://discourse.nodered.org/u/swanside)\
**Post date:** [22 May 2021 05:12 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/1 "2021-05-22T05:12:53Z")

</div>

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

```auto
[{"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"]]}]

```

```auto
[{"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}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 May 2021 06:58 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/2 "2021-05-22T06:58:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![swanside](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/swanside/32/28781_2.png) [@swanside](https://discourse.nodered.org/u/swanside)\
**Post date:** [22 May 2021 09:10 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/3 "2021-05-22T09:10:12Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/c/7c63258af4a048461c54f75bce3a63718d98bad5.png)

---

<div class="post-metadata">

**Author:** ![swanside](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/swanside/32/28781_2.png) [@swanside](https://discourse.nodered.org/u/swanside)\
**Post date:** [22 May 2021 09:23 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/4 "2021-05-22T09:23:40Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/9/59b508241bc64a9f5d135377e8a7d9af8da3bc98.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [22 May 2021 09:32 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/5 "2021-05-22T09:32:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![swanside](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/swanside/32/28781_2.png) [@swanside](https://discourse.nodered.org/u/swanside)\
**Post date:** [22 May 2021 09:51 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/6 "2021-05-22T09:51:16Z")

</div>

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!!!!

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/b/2b12b509db0cfe6333ace244ba385e41380b6814.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [22 May 2021 10:30 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/7 "2021-05-22T10:30:45Z")

</div>

> [@swanside](#):
>
> It has the undefines which I an guessing are the top two

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.

---

<div class="post-metadata">

**Author:** ![swanside](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/swanside/32/28781_2.png) [@swanside](https://discourse.nodered.org/u/swanside)\
**Post date:** [22 May 2021 10:38 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/8 "2021-05-22T10:38:51Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/0/a033a3148b03f714610e47101eaae59ae0471de4.png)

---

<div class="post-metadata">

**Author:** ![swanside](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/swanside/32/28781_2.png) [@swanside](https://discourse.nodered.org/u/swanside)\
**Post date:** [22 May 2021 11:02 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/9 "2021-05-22T11:02:52Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1c5072a3547caf9dc802e3a364cbbdeb2a25277a.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [22 May 2021 12:25 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/10 "2021-05-22T12:25:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![swanside](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/swanside/32/28781_2.png) [@swanside](https://discourse.nodered.org/u/swanside)\
**Post date:** [23 May 2021 09:46 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/11 "2021-05-23T09:46:59Z")

</div>

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?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d499492e4b650ca7cfced7982585b4fd3f67d93d.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1cff662445be768b35acfd679de19f7afc6b30b5.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 May 2021 09:49 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/12 "2021-05-23T09:49:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![swanside](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/swanside/32/28781_2.png) [@swanside](https://discourse.nodered.org/u/swanside)\
**Post date:** [23 May 2021 09:51 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/13 "2021-05-23T09:51:27Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/9/299d724d1949d6526a7240c34e2bbc04e61bdd19.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 May 2021 09:57 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/14 "2021-05-23T09:57:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![swanside](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/swanside/32/28781_2.png) [@swanside](https://discourse.nodered.org/u/swanside)\
**Post date:** [23 May 2021 10:15 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/15 "2021-05-23T10:15:36Z")

</div>

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?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/6/c688d0dbd778a852d7d10f60ebb5093a8a48e996.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 May 2021 10:29 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/16 "2021-05-23T10:29:08Z")

</div>

> [@swanside](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![swanside](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/swanside/32/28781_2.png) [@swanside](https://discourse.nodered.org/u/swanside)\
**Post date:** [23 May 2021 10:33 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/17 "2021-05-23T10:33:16Z")

</div>

It works correctly with the same settings using a test

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fbae18e6fc7da414e92e776ba8fc7ece7dab12c4.png)

---

<div class="post-metadata">

**Author:** ![swanside](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/swanside/32/28781_2.png) [@swanside](https://discourse.nodered.org/u/swanside)\
**Post date:** [23 May 2021 10:45 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/18 "2021-05-23T10:45:34Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/22bbf13593014d3607d3c0edcc1ca53954d0a23b.png)

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/0/305fbe33935cea48f653ad0dd7e698dcc37cdb34.png)

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/e/7eab757de5f302e25287184b2ffc683622110374.png)

and it just goes on, and on

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/3/e34e7a4fe6b45ed1a8590cca3f3e5dab0f605447.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 May 2021 11:51 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/19 "2021-05-23T11:51:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![swanside](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/swanside/32/28781_2.png) [@swanside](https://discourse.nodered.org/u/swanside)\
**Post date:** [23 May 2021 12:07 UTC](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064/20 "2021-05-23T12:07:34Z")

</div>

Did that and it sends the correct info

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/14ce08d603b35ec2f3f4e7ae0673e03983cc8edb.png)

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/2/a292c5fc3bd8022a5a3e816257c0905aaebe6947.png)

[Next page](https://discourse.nodered.org/t/typeerror-cannot-read-property-tostring-of-undefined/46064.md?page=2)
