Node red not displaying ram data


#1

This is the flow im using,

[{"id":"29c5c29f.0ccade","type":"ui_gauge","z":"5bbec9a5.28ca08","name":"","group":"c998f325.2a7bc","order":2,"width":0,"height":0,"gtype":"gage","title":"CPU Temperature","label":"Degrees F","format":"{{value}}","min":"40","max":"150","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1099,"y":104,"wires":[]},{"id":"756e68c1.63f4f8","type":"exec","z":"5bbec9a5.28ca08","command":"vcgencmd measure_temp","addpay":false,"append":"","useSpawn":"","timer":"","name":"RPi Temp.","x":496,"y":137,"wires":[["cd08e15.bd9662"],[],[]]},{"id":"8c053f83.c1a2c","type":"inject","z":"5bbec9a5.28ca08","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":"","x":290.5,"y":145.25,"wires":[["756e68c1.63f4f8","97a598e9.2e0018","7a86592f.679968"]]},{"id":"cd08e15.bd9662","type":"function","z":"5bbec9a5.28ca08","name":"","func":"str = msg.payload\nmsg.payload = str.substring(5,9);\nreturn msg;","outputs":1,"noerr":0,"x":676,"y":137,"wires":[["a845c6d0.b035e8"]]},{"id":"264838c0.f9ead8","type":"ui_button","z":"5bbec9a5.28ca08","name":"","group":"ca8f3c67.b213c","order":2,"width":0,"height":0,"label":"Reboot","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":266,"y":517,"wires":[["5ce5c280.b83d4c"]]},{"id":"5ce5c280.b83d4c","type":"exec","z":"5bbec9a5.28ca08","command":"sudo reboot","addpay":false,"append":"","useSpawn":"","timer":"","name":"Reboot","x":484,"y":517,"wires":[[],[],[]]},{"id":"f82e6c7a.7c664","type":"ui_button","z":"5bbec9a5.28ca08","name":"","group":"ca8f3c67.b213c","order":3,"width":0,"height":0,"label":"Shutdown","color":"","bgcolor":"red","icon":"","payload":"","payloadType":"str","topic":"","x":274.5,"y":561.25,"wires":[["8b933e22.73a26"]]},{"id":"8b933e22.73a26","type":"exec","z":"5bbec9a5.28ca08","command":"sudo shutdown -h now","addpay":false,"append":"","useSpawn":"","timer":"","name":"Shutdown","x":495.5,"y":579.25,"wires":[[],[],[]]},{"id":"b21ec346.6e944","type":"ui_chart","z":"5bbec9a5.28ca08","name":"","group":"c998f325.2a7bc","order":3,"width":0,"height":0,"label":"","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":"24","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":true,"x":1089,"y":163,"wires":[[],[]]},{"id":"97a598e9.2e0018","type":"exec","z":"5bbec9a5.28ca08","command":"top -d 0.5 -b -n2 | grep \"Cpu(s)\"|tail -n 1 | awk '{print $2 + $4}'","addpay":false,"append":"","useSpawn":"","timer":"","name":"CPU Load","x":496,"y":217,"wires":[["3ad9f72a.5cd698"],[],[]]},{"id":"7a86592f.679968","type":"exec","z":"5bbec9a5.28ca08","command":"free | grep Mem | awk '{print 100*($4+$6+$7)/$2}'","addpay":false,"append":"","useSpawn":"","timer":"","name":"Free Memory","x":496,"y":297,"wires":[["f6b57c6b.c6224","8f6b01b5.29a2"],[],[]]},{"id":"3ad9f72a.5cd698","type":"ui_gauge","z":"5bbec9a5.28ca08","name":"","group":"c998f325.2a7bc","order":1,"width":0,"height":0,"gtype":"gage","title":"Processor","label":"CPU % Usage","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":856,"y":217,"wires":[]},{"id":"f6b57c6b.c6224","type":"ui_gauge","z":"5bbec9a5.28ca08","name":"","group":"dd04219d.3c55d","order":1,"width":0,"height":0,"gtype":"gage","title":"Memory","label":"RAM","format":"{{value.toFixed(1)}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"x":856,"y":297,"wires":[]},{"id":"efb4235d.83a2e","type":"exec","z":"5bbec9a5.28ca08","command":"df -h","addpay":false,"append":"","useSpawn":"","timer":"","name":"Disk Usage","x":496,"y":377,"wires":[["441ec2d8.919dac"],[],[]]},{"id":"4ef67924.4a3d48","type":"ui_gauge","z":"5bbec9a5.28ca08","name":"","group":"67638498.5c2e5c","order":1,"width":0,"height":0,"gtype":"gage","title":"Disk","label":"Usage","format":"{{value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"x":856,"y":377,"wires":[]},{"id":"441ec2d8.919dac","type":"function","z":"5bbec9a5.28ca08","name":"","func":"var re = /([0-9]{2})%/\nvar idx = msg.payload.search(re);\nvar str = msg.payload;\nif (idx >=0) {\n    str = msg.payload.substring(idx, idx + 2);\n}\nmsg.payload = str;\nreturn msg;","outputs":1,"noerr":0,"x":676,"y":377,"wires":[["4ef67924.4a3d48"]]},{"id":"71c53119.f34e6","type":"inject","z":"5bbec9a5.28ca08","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":"","x":296,"y":377,"wires":[["efb4235d.83a2e"]]},{"id":"a845c6d0.b035e8","type":"function","z":"5bbec9a5.28ca08","name":"convert C to F","func":"var tempc = msg.payload;\n    tempf = tempc * 9/5 + 32;\n    tempf = Math.round(tempf * 10) / 10;\n    msg.payload = tempf;\n    return msg;\n","outputs":1,"noerr":0,"x":870,"y":125,"wires":[["29c5c29f.0ccade","b21ec346.6e944"]]},{"id":"8f6b01b5.29a2","type":"debug","z":"5bbec9a5.28ca08","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1100,"y":322,"wires":[]},{"id":"c998f325.2a7bc","type":"ui_group","z":"","name":"Col1","tab":"19ff6ee5.9a1551","order":1,"disp":false,"width":"6"},{"id":"ca8f3c67.b213c","type":"ui_group","z":"","name":"Actions","tab":"19ff6ee5.9a1551","order":4,"disp":true,"width":"6"},{"id":"dd04219d.3c55d","type":"ui_group","z":"","name":"Col2","tab":"19ff6ee5.9a1551","order":2,"disp":false,"width":"6"},{"id":"67638498.5c2e5c","type":"ui_group","z":"","name":"Col3","tab":"19ff6ee5.9a1551","order":3,"disp":false,"width":"6"},{"id":"19ff6ee5.9a1551","type":"ui_tab","z":"","name":"RPi Control","icon":"dashboard","order":1}]

My issue is it wont show the ram data. Im getting a error in debug of
"TypeError: Cannot read property 'toFixed(1)' of undefined


#2

Which node is giving that error? If you hover over the error the node should be highlighted. Alternatively give all your nodes names and then the name should be displayed.
Once you work out which node put a debug node showing what is going into that node and check that the message you are sending it looks ok.


#3

Are you sending a number or a string to the gauge? Turn on your debug node and look at the results.


#4

Thats the free memory function node. The error im getting is from the degug node on the output of the function node.


#5

try changing the Value format to {{value | number:1}}%


#6

I suspect that is not correct, I suspect it is the gauge as @zenofmud has suggested. It is likely caused by the fact you are sending it a string (containing a number) not an actual number.


#7

Sorry i just realized its a execute node. Its command is free | grep Mem | awk '{print 100*($4+$6+$7)/$2}'


#8

Have you made the change to the gauge?


#9

I changed it and now it works. Even the debug displays it correctly. I thought the debug just forwarded what was being outputted?


#10

It displays whatever is given to it, the error was not coming from the debug, it was coming from the gauge.