Rev 79 | Blame | Compare with Previous | Last modification | View Log | Download
# Ookla Speedtest CLI integrationHave been using the speedtest-cli integrationfor some years, but yesterday swapped to the "speedtest" CLI provided byOokla. The original speedtest-cli worked well, except for thelatency/ping measurements. The Ookla speedtest does measure the pingcorrectly, 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 sensors2) store scripts somewhere (e.g. ~/domoticz/scripts)see below for content3) modify IDXs in script with IDXs of your virtual sensors4) remove speedtest-cli (if installed)sudo apt-get remove speedtest-cli5) install speedtest from Ookla,see [Speedtest CLI - Internet connection measurement for developers](https://www.speedtest.net/apps/cli) (see Ubuntu/Debian)check it works6) install jqsudo apt-get install jq)7) verify the script workscheck the port on which domoticz runs 8) create a crontab entry to schedule it.#speedtest5,20,35,50 * * * * ~/domoticz/scripts/ooklaspeed.sh > /dev/null 2>&1Speedtest.jpg (99.89 KiB) Viewed 2110 timesspeedtest trend.jpg (121.03 KiB) Viewed 2110 times------------script content----------------------```bash#!/bin/bash# make sure jq is installed# sudo apt-get install jq# define domoticz connectionhost=192.168.2.107port=8080# define ids for domoticz sensors for hostidxpng=3idxul=2idxdl=1idxjit# define location for filefile=/home/marcel/domoticz/ookla.json# execute the speedtest and store result.# speedtest --accept-gdpr -f json-pretty > $filespeedtest --accept-gdpr -f json-pretty --server-id=5252 > $filedownraw=$(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 manuallyecho "download = $download Mbps"echo "upload = $upload Mbps"echo "ping = $png ms"echo "jitter = $jit ms"# upload result to Domiticzcurl "http://$host:$port/json.htm?username=cGk=&password=TWFyZ3IhZXRANzA=&type=command¶m=udevice&idx=$idxdl&svalue=$downl$curl "http://$host:$port/json.htm?username=cGk=&password=TWFyZ3IhZXRANzA=&type=command¶m=udevice&idx=$idxul&svalue=$uploa$curl "http://$host:$port/json.htm?username=cGk=&password=TWFyZ3IhZXRANzA=&type=command¶m=udevice&idx=$idxpng&svalue=$png"$curl "http://$host:$port/json.htm?username=cGk=&password=TWFyZ3IhZXRANzA=&type=command¶m=udevice&idx=$idxjit&svalue=$jit"$```## Install Oookla speed test```bashsudo apt-get install gnupg1 apt-transport-https dirmngrexport INSTALL_KEY=379CE192D401AB61sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $INSTALL_KEYecho "deb https://ookla.bintray.com/debian generic main" | sudo tee /etc/apt/sources.list.d/speedtest.listsudo apt-get update```Other non-official binaries will conflict with Speedtest CLIExample how to remove using apt-getsudo apt-get remove speedtest-cli```sudo apt-get install speedtest```