Skip to content

Instantly share code, notes, and snippets.

@DeepPurple77
Created October 26, 2016 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeepPurple77/e3e8c7f4807f383ab85d61ff2dfda208 to your computer and use it in GitHub Desktop.
Save DeepPurple77/e3e8c7f4807f383ab85d61ff2dfda208 to your computer and use it in GitHub Desktop.
Internet Speedtest (with Charts and Guages)

This flow is based on the excellent flow developed by "bloigge". The original flow can be found here: http://flows.nodered.org/flow/b79e4d9cfc4b474b9975a8bb3b80fb64

This flow checks the current Internet Speed and logs the data to various gauges and charts in a UI Dashboard. It runs on the hour of each hour, i.e. 10am, 11am, 12pm etc. It also allows the test to be invoked manually should the user want to do an immediate test from the dashboard.

PreSettings (as per the original instructions):

Install speedtest_cli:

wget -O speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py chmod +x speedtest-cli

Requires: Node-Red UI (http://flows.nodered.org/node/node-red-contrib-ui)

[{"id":"ce56eb75.26c998","type":"exec","z":"8fde001d.7f357","command":"/home/deeppurple/speedtest-cli","addpay":false,"append":"","useSpawn":"","timer":"","name":"Call Speedtest-cli","x":287.5,"y":359.6666564941406,"wires":[["94166ade.706f58"],[],[]]},{"id":"94166ade.706f58","type":"function","z":"8fde001d.7f357","name":"Data Preparation for File","func":"var content = msg.payload.split(\"\\n\");\nvar msgDown = {topic: \"Download\", payload: parseFloat(content[6].split(\" \")[1])};\nvar msgUp = {topic: \"Upload\", payload: parseFloat(content[8].split(\" \")[1])};\n\nvar hostedBy = content[4];\nvar ping = {topic: \"Ping\", payload: hostedBy.split(\":\")[1]};\nvar distance = {topic: \"Distance\", payload: hostedBy.split(\"[\")[1].split(\"]\")[0]};\nvar ISP = {payload: hostedBy.split(\"Hosted by\")[1].split(\"[\")[0]};\n\nfunction getTimeStamp() {\n var date = new Date();\n var year = date.getFullYear();\n var month = (\"0\"+(date.getMonth()+1)).substr(-2);\n var day = (\"0\"+date.getDate()).substr(-2);\n var hour = (\"0\"+date.getHours()).substr(-2);\n var minutes = (\"0\"+date.getMinutes()).substr(-2);\n var seconds = (\"0\"+date.getSeconds()).substr(-2);\n return year+\"-\"+month+\"-\"+day+\" \"+hour+\":\"+minutes+\":\"+seconds;\n}\n \nvar time = {payload: getTimeStamp()};\n\nreturn [msgDown, msgUp, time, ping, distance, ISP];","outputs":"6","noerr":0,"x":547,"y":349,"wires":[["6045fb71.a8e564","70d2e4d4.f12c4c","bdfe0e4.729ddf"],["70d2e4d4.f12c4c","6045fb71.a8e564","ffb5dc4.a20f12"],["bc28449f.5b32f8","6045fb71.a8e564"],["2ef6b383.b6375c","ea99deea.4cbb1"],["ccdd57a9.f416d8","ea99deea.4cbb1"],["e97e7ff1.291b1"]]},{"id":"378e1aeb.490496","type":"inject","z":"8fde001d.7f357","name":"Second Tick","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"x":129.5,"y":149,"wires":[["3f5b327f.c29e1e"]]},{"id":"6045fb71.a8e564","type":"debug","z":"8fde001d.7f357","name":"","active":false,"console":"false","complete":"true","x":956.5,"y":165,"wires":[]},{"id":"70d2e4d4.f12c4c","type":"ui_chart","z":"8fde001d.7f357","name":"Performance Chart","group":"6ad43cb5.1fb1e4","order":0,"width":0,"height":0,"label":"Performance Chart","chartType":"line","legend":"true","xformat":"%H:%M:%S","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":1,"removeOlderUnit":"604800","x":959.5,"y":231,"wires":[["fbfbb7f2.6c9f08"],[]]},{"id":"fbfbb7f2.6c9f08","type":"file","z":"8fde001d.7f357","name":"Speed Test Data Save","filename":"speedtestData.json","appendNewline":false,"createDir":false,"overwriteFile":"true","x":1197.5,"y":199,"wires":[]},{"id":"81b8d40a.a899c8","type":"file in","z":"8fde001d.7f357","name":"Speed Test Data Restore","filename":"speedtestData.json","format":"utf8","x":1200.5,"y":252,"wires":[["ffcd7703.b04478"]]},{"id":"ffcd7703.b04478","type":"json","z":"8fde001d.7f357","name":"","x":1161.5,"y":143,"wires":[["70d2e4d4.f12c4c"]]},{"id":"bdfe0e4.729ddf","type":"ui_gauge","z":"8fde001d.7f357","name":"","group":"a1aa2891.55e438","order":6,"width":0,"height":0,"gtype":"gage","title":"Download Speed","label":"Download Mbits","format":"{{value}}","min":0,"max":"20","colors":["#ff002d","#e4b400","#03f81f"],"x":947.5,"y":387,"wires":[]},{"id":"ffb5dc4.a20f12","type":"ui_gauge","z":"8fde001d.7f357","name":"","group":"a1aa2891.55e438","order":7,"width":0,"height":0,"gtype":"gage","title":"Upload Speed","label":"Upload MBits","format":"{{value}}","min":0,"max":"20","colors":["#ff002d","#ffed36","#03f81f"],"x":947,"y":440,"wires":[]},{"id":"bc28449f.5b32f8","type":"ui_text","z":"8fde001d.7f357","group":"a1aa2891.55e438","order":1,"width":0,"height":0,"name":"Latest Speedtest","label":"Lastest Speedtest","format":"<font color=\"cyan\">{{msg.payload}}</font>","layout":"col-center","x":955.5,"y":489,"wires":[]},{"id":"b4c22453.c329d8","type":"ui_button","z":"8fde001d.7f357","name":"","group":"a1aa2891.55e438","order":3,"width":0,"height":0,"label":"SpeedTest Now!","color":"","icon":"","payload":"","payloadType":"date","topic":"","x":148.5,"y":507,"wires":[["ce56eb75.26c998"]]},{"id":"a97c5c09.b8dc4","type":"inject","z":"8fde001d.7f357","name":"","topic":"","payload":"restore","payloadType":"str","repeat":"","crontab":"","once":true,"x":933.5,"y":284,"wires":[["81b8d40a.a899c8","33685a3a.458306"]]},{"id":"3f5b327f.c29e1e","type":"function","z":"8fde001d.7f357","name":"Get Hour","func":"function gethour() {\n var date = new Date();\n var hour = (\"0\"+date.getHours()).substr(-2);\n return hour;\n}\n\nvar hour=gethour();\n\nmsg = {payload:hour};\nreturn msg;\n","outputs":1,"noerr":0,"x":299.5,"y":149,"wires":[["4f17a87f.cc5ba8"]]},{"id":"4f17a87f.cc5ba8","type":"rbe","z":"8fde001d.7f357","name":"","func":"rbe","gap":"","start":"","inout":"out","x":436.5,"y":149,"wires":[["ce56eb75.26c998"]]},{"id":"e97e7ff1.291b1","type":"ui_text","z":"8fde001d.7f357","group":"a1aa2891.55e438","order":2,"width":0,"height":0,"name":"","label":"Hosted By","format":"<font color=\"cyan\">{{msg.payload}}</font>","layout":"col-center","x":938.5,"y":612,"wires":[]},{"id":"ccdd57a9.f416d8","type":"ui_text","z":"8fde001d.7f357","group":"a1aa2891.55e438","order":5,"width":0,"height":0,"name":"","label":"Distance","format":"<font color=\"cyan\">{{msg.payload}}</font>","layout":"col-center","x":927,"y":574,"wires":[]},{"id":"2ef6b383.b6375c","type":"ui_text","z":"8fde001d.7f357","group":"a1aa2891.55e438","order":4,"width":0,"height":0,"name":"","label":"Ping Time","format":"<font color=\"cyan\">{{msg.payload}}</font>","layout":"col-center","x":929,"y":535,"wires":[]},{"id":"c0e5af5.a4e385","type":"file","z":"8fde001d.7f357","name":"Speed Test Data Save","filename":"speedtestDataPD.json","appendNewline":false,"createDir":false,"overwriteFile":"true","x":1192,"y":295,"wires":[]},{"id":"33685a3a.458306","type":"file in","z":"8fde001d.7f357","name":"Speed Test Data Restore","filename":"speedtestDataPD.json","format":"utf8","x":1200,"y":344,"wires":[["446f355b.a0592c"]]},{"id":"446f355b.a0592c","type":"json","z":"8fde001d.7f357","name":"","x":1166.5,"y":411,"wires":[["ea99deea.4cbb1"]]},{"id":"ea99deea.4cbb1","type":"ui_chart","z":"8fde001d.7f357","name":"Latency Chart","group":"6ad43cb5.1fb1e4","order":0,"width":0,"height":0,"label":"Latency Chart","chartType":"line","legend":"true","xformat":"%H:%M:%S","interpolate":"linear","nodata":"","ymin":"","ymax":"","removeOlder":1,"removeOlderUnit":"604800","x":961,"y":332,"wires":[["c0e5af5.a4e385"],[]]},{"id":"6ad43cb5.1fb1e4","type":"ui_group","z":"","name":"Chart","tab":"ca2c9b5d.7d3298","order":2,"disp":false,"width":"12"},{"id":"a1aa2891.55e438","type":"ui_group","z":"","name":"Graphs","tab":"ca2c9b5d.7d3298","order":1,"disp":false,"width":"6"},{"id":"ca2c9b5d.7d3298","type":"ui_tab","z":"","name":"SpeedTest History","icon":"dashboard","order":3}]
@ovizii
Copy link

ovizii commented Nov 28, 2016

Seems to be missing stuff, not sure what node though?
I get these errors when importing:

Imported unrecognized types
ui_chart
ui_text
ui_button
ui_gauge
ui_group

node-red-contrib-ui is installed. on a hunch I even tried node-red-contrib-ui_j but that didn't help either

@thebaldgeek
Copy link

@ovizii You need to uninstall the node-red-contrib-ui, restart nodeRed and then install node-red-dashboard. Once I did that, everything worked as expected.

@deeppurple speedtest-cli.py has been depreciated and no longer works, the file is now called speedtest.py.
If you could tweak your flow here and on flows.nodered.org it would 'just work'.

@cyberlacs
Copy link

I'm using a Raspberry with Raspbian Node Red.

The question is
How do I install Internet Test on Node Red, I would describe how to do the installation.

@Henkkas52
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment