Ookla Speedtest CLI integration
Posted: Saturday 28 March 2020 16:15
Have been using the speedtest-cli integration for some years, but yesterday swapped to the "speedtest" CLI provided by Ookla. The original speedtest-cli worked well, except for the latency/ping measurements. The Ookla speedtest does measure the ping correctly, so therefore a step forward.
Please note that you can't have them both installed at same time
Maybe this info saves some other people a bit of time to get this running.
1) create dummy sensors
2) store scripts somewhere (e.g. ~/domoticz/scripts)
see below for content
3) modify IDXs in script with IDXs of your virtual sensors
4a) remove speedtest-cli (if installed)
sudo apt-get remove speedtest-cli
4b) install speedtest from Ookla,
see https://www.speedtest.net/apps/cli (see Ubuntu/Debian)
check it works
5) install jq
sudo apt-get install jq)
6) verify the script works
check the port on which domoticz runs
7) create a crontab entry to schedule it.
#speedtest
5,20,35,50 * * * * ~/domoticz/scripts/ooklaspeed.sh > /dev/null 2>&1
------------script content----------------------
#!/bin/bash
# make sure jq is installed
# sudo apt-get install jq
# define domoticz connection
host=127.0.0.1
port=80
# define ids for domoticz sensors
idxpng=69
idxul=70
idxdl=71
idxjit=122
# define location for file
file=~/ookla.json
# execute the speedtest and store result.
speedtest -f json-pretty > $file
downraw=$(jq -r '.download.bandwidth' $file)
download=$(printf %.2f\\n "$((downraw * 8))e-6")
upraw=$(jq -r '.upload.bandwidth' $file)
upload=$(printf %.2f\\n "$((upraw * 8))e-6")
png=$(jq -r '.ping.latency' $file)
jit=$(jq -r '.ping.jitter' $file)
#output if you run it manually
echo "download = $download Mbps"
echo "upload = $upload Mbps"
echo "ping = $png ms"
echo "jitter = $jit ms"
# upload result to Domiticz
curl "http://$host:$port/json.htm?type=command¶m=udevice&idx=$idxdl&svalue=$download" > /dev/null 2>&1
curl "http://$host:$port/json.htm?type=command¶m=udevice&idx=$idxul&svalue=$upload" > /dev/null 2>&1
curl "http://$host:$port/json.htm?type=command¶m=udevice&idx=$idxpng&svalue=$png" > /dev/null 2>&1
curl "http://$host:$port/json.htm?type=command¶m=udevice&idx=$idxjit&svalue=$jit" > /dev/null 2>&1
Please note that you can't have them both installed at same time
Maybe this info saves some other people a bit of time to get this running.
1) create dummy sensors
2) store scripts somewhere (e.g. ~/domoticz/scripts)
see below for content
3) modify IDXs in script with IDXs of your virtual sensors
4a) remove speedtest-cli (if installed)
sudo apt-get remove speedtest-cli
4b) install speedtest from Ookla,
see https://www.speedtest.net/apps/cli (see Ubuntu/Debian)
check it works
5) install jq
sudo apt-get install jq)
6) verify the script works
check the port on which domoticz runs
7) create a crontab entry to schedule it.
#speedtest
5,20,35,50 * * * * ~/domoticz/scripts/ooklaspeed.sh > /dev/null 2>&1
------------script content----------------------
#!/bin/bash
# make sure jq is installed
# sudo apt-get install jq
# define domoticz connection
host=127.0.0.1
port=80
# define ids for domoticz sensors
idxpng=69
idxul=70
idxdl=71
idxjit=122
# define location for file
file=~/ookla.json
# execute the speedtest and store result.
speedtest -f json-pretty > $file
downraw=$(jq -r '.download.bandwidth' $file)
download=$(printf %.2f\\n "$((downraw * 8))e-6")
upraw=$(jq -r '.upload.bandwidth' $file)
upload=$(printf %.2f\\n "$((upraw * 8))e-6")
png=$(jq -r '.ping.latency' $file)
jit=$(jq -r '.ping.jitter' $file)
#output if you run it manually
echo "download = $download Mbps"
echo "upload = $upload Mbps"
echo "ping = $png ms"
echo "jitter = $jit ms"
# upload result to Domiticz
curl "http://$host:$port/json.htm?type=command¶m=udevice&idx=$idxdl&svalue=$download" > /dev/null 2>&1
curl "http://$host:$port/json.htm?type=command¶m=udevice&idx=$idxul&svalue=$upload" > /dev/null 2>&1
curl "http://$host:$port/json.htm?type=command¶m=udevice&idx=$idxpng&svalue=$png" > /dev/null 2>&1
curl "http://$host:$port/json.htm?type=command¶m=udevice&idx=$idxjit&svalue=$jit" > /dev/null 2>&1