Speedtest CLI by Ookla - Internet Up-/Downlink Measurement Integration

Hi All,
For those that want to leverage the opportunity to see additional info regarding the ISP and Speedtest Host I have a working example that you can use freely. Just ad the the sections below in your environment.
You can (but not need to) target a specific server as outlined in this tutorial in the above posts. I personally use a nearby server and edited that call in the speedtest.rules file:

val speedtestExecute = "speedtest -f json -s 13883"

Happy Speedtesting :slight_smile:

Items (speedtest.items)

// Additions
String		SpeedtestISP			"Internet Service Provider [%s]"
String		SpeedtestId				"Speedtest Host ID [%s]"
String		SpeedtestName			"Speedtest Host [%s]"
String		SpeedtestLocation		"Location [%s]"
String		SpeedtestCountry		"Country [%s]"
String		SpeedtestHost			"Host URL [%s]"

Sitemap (your.sitemap)

                Frame label="Speedtest Provider Details"
                {
                    Text item=SpeedtestISP
                    Text item=SpeedtestId 
                    Text item=SpeedtestName
                    Text item=SpeedtestLocation
                    Text item=SpeedtestCountry
                    Text item=SpeedtestHost
                }

Rules (speedtest.rules)
Just use this in the main section of your speedtest.rules file

        // Get Target Server Details
        SpeedtestISP.sendCommand(transform("JSONPATH", "$.isp", speedtestCliOutput))
        SpeedtestId.sendCommand(transform("JSONPATH", "$.server.id", speedtestCliOutput))
        SpeedtestName.sendCommand(transform("JSONPATH", "$.server.name", speedtestCliOutput))
        SpeedtestLocation.sendCommand(transform("JSONPATH", "$.server.location", speedtestCliOutput))
        SpeedtestCountry.sendCommand(transform("JSONPATH", "$.server.country", speedtestCliOutput))
        SpeedtestHost.sendCommand(transform("JSONPATH", "$.server.host", speedtestCliOutput))

Thanks,
Edward

3 Likes

Hej @Bredmich - really nice solution! Congrats.
As you seem to have more knowledge about speedtests a question concerning the principle difference between the solutions.
The network binding offers as well a speedtest. Here one can define the speedtest server to use (e.g. the anycasted server adress http://speedtest.tele2.net) , as well as the file to use (as e.g. described here by Tele2. I tried to benchmark the use of the network binding against the use of the Speedtest by Ookla. I get the same results, when both use the same server (and not the one, which is set by default in the network binding)

Do you think there is a principle difference in the two approaches (except, that the Speedtest CLI results are way more detailed) ?

Hi Martin,
i´m afraid i can´t answer that from a technical point of view.
A Speedtest i basically just a down-/upload that is measured.
I don´t think that there´s a difference between a speedtest measured by the network-binding or with the Speedtest CLI.
But that´s just my point of view and maybe someone has more knowledge about Speedtests.

kind regards
Michael

Sometimes it works, but most of the time I get this error:

2020-04-19 20:24:59.221 [ERROR] [pse.smarthome.model.script.Speedtest] - --> speedtest failed. Output:
{"type":"log","timestamp":"2020-04-19T18:24:30Z","message":"Error: [11] Cannot read from socket: Resource temporarily unavailable","level":"error"}
{"type":"result","timestamp":"2020-04-19T18:24:59Z","ping":{"jitter":0.57799999999999996,"latency":6.4829999999999997},"download":{"bandwidth":11032873,"bytes":130671864,"elapsed":12602},"upload":{"bandwidth":26750187,"bytes":383575374,"elapsed":15008},"packetLoss":0,"isp":"xxx","interface":{"internalIp":"xxx","name":"eth0","macAddr":"xxx","isVpn":false,"externalIp":"xxx"},"server":{"id":21509,"name":"i3D.net","location":"Rotterdam","country":"Netherlands","host":"eu.speedtest.i3d.net","port":8080,"ip":"213.163.76.135"},"result":{"id":"a9ff64fd-2e43-4f7d-a340-2920151aa027","url":"https://www.speedtest.net/result/c/a9ff64fd-2e43-4f7d-a340-2920151aa027"}}

I changed your “fairly simple error check” to:

if (speedtestCliOutput.startsWith("{\"type\":") && speedtestCliOutput.endsWith("}}"))

Hi Stefan,

i´m sorry but i can´t tell you what this error means, cause it´s coming from the Speedtest CLI and not openHAB.
Whats your value for val speedtestExecute = "speedtest -f json"?

It seems like the speedtest itself runs fine but you´re getting the typ:log with the message [11] Cannot read from socket: Resource temporarily unavailable right before the correct output.
Maybe you should try to contact Ookla directly: support@ookla.com

kind regards
Michael

1 Like

Thanks for your scripts :slight_smile:
I have also migrated my previous scripts to this version. Now the speedtests are constant and much faster with the previous speedtest_cli…
I thought that my ISP is not so great that’s why I get these variations in speed, but it turns out not :slight_smile:

Ps.: Now I will have to migrate this rule to Python (NGRE)…

Hello to everyone,

I have installed before Sivel’s implementation on my Raspberry Pi and found performance issues so I upgraded to a Raspberry Pi 2 and obtained better results. Recently I started having problems with servers not being available even though they were working on speedtest.net, so I found out about Ookla’s implementation.

I’m curious about Speedtest CLI by Ookla. Does anybody know if this implementation is proprietary software? Because I already verified way less processing required by Ookla’s implementation on my Raspberry Pi 2, but I could not find a repository in Ookla’s GitHub Team related to the cli.

Best regards

I think it is not open-sourced but definitely proprietary software.
You can even find install guides and the related info on speedtest.net, here:
https://www.speedtest.net/apps/cli

1 Like

Just wanted to update @Bredmich that I have added a small enhancement to your excellent implementation of the OH speed test.

With my whole family at home all on the internet, using Zoom, Microsoft Teams, and other video conferencing platforms speed was always a concern. In fact when other members experienced video issues they were always blaming the internet bandwidth which I was keeping an eye on thanks to your great work.

So if I was on a call and they wanted to know how our internet connection was performing they were a bit out of luck as they don’t typically interact with OH via the GUI…only through Alexa!

So I created a routine in Node-Red that pulls the speed values from OH and makes them available via a question to an Amazon Echo Device.

Human - “Alexa, what is the internet speed at the house?”

Alexa - " "Looks like the download speed is 956 Mega Bits, The upload speed is 42 Mega Bits, and the packet ping time is 5 Milliseconds"

It works flawlessly and with all the traffic going on in the house it makes it a bit easier on me that the fam can do a bit of investigating before they call on me to assist.

Happy to share the flow with any one who wants/needs it.

Squid :squid:

2 Likes

The speed test on Raspberry pi3b+ is giving the following error. This was working fine till two hours back.
To make it up I tried :

  1. Update and Upgrade
  2. Removed Speedtest and Reinstalled
    sudo apt-get remove speedtest
    sudo apt-get install speedtest
    Still the following error
pi@raspberrypi:~/drive/donottouch/rpibackup $ speedtest
[2020-05-27 02:37:02.663] [error] Configuration - Cannot retrieve configuration document (301)
[2020-05-27 02:37:02.664] [error] ConfigurationError - Could not retrieve or read configuration (Configuration)
[2020-05-27 02:37:02.669] [error] ConfigurationError - Could not retrieve or read configuration (Configuration)
[error] Configuration - Could not retrieve or read configuration (ConfigurationError)

Hey @sujitrp maybe a bit late for an anwer, but i had this problem too and it was on side of the speedtest provider ookla.
I have reported it and they have fixed that very quick.
Just if someone is facing similiar problems a report to the test provider should be a valid solution.

See:

And the answer:

1 Like

Yes it is working now

probably a numb question but i couldn’t figure it out…
what path exactly do i put in there? (raspian)

edit: okay, i just figured out how to find the path of a script… maybe this will help some idot (like me) :

openhabian@OHab2:~$ readlink -f speedtest
/home/openhabian/speedtest

Sorry i just got back to the exec binding version without whitelisting because it wasn´t working as excepted in the first release.
Maybe i should give it another try…

I get on error installing the key.
All steps work until:

[09:26:06] openhabian@openhab:~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $INSTALL_KEY
Executing: /tmp/apt-key-gpghome.7tS2cM7bgO/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 379CE192D401AB61
gpg: keyserver receive failed: Server indicated a failure

After this it wont install the speedtest from Ookla

[09:28:22] openhabian@openhab:~$ sudo apt-get install speedtest
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package speedtest

Is this an error with Ookla or do I need to change something?
Thanks

I would guess this is an error with apt-key as the key isn´t from Ookla.
This key is also used for other packages.
Try to contact them over twitter: https://twitter.com/Speedtest

kind regards
Michael

Hmm same here, but i don´t get any keyserver failure :face_with_monocle:

got it working, i reinstalled the key and did another apt-get update

Now I get a new error

E: The repository 'https://ookla.bintray.com/debian buster Release' is not signed.

E: Unable to locate package speedtest

Seems to be an issue with Ookla

Yes, that´s an issue with Ookla.
Please contact them through Twitter.

I have via their support e-mail, just waiting for a reply.
I will let you know if / when it is fixed for me.