Ookla's Speedtest Binding [3.2.0;3.9.0)

I changed this:

sudo apt-get install speedtest

To this:

sudo apt-get install speedtest-cli

Which installed without issue. I could then run speedtest or speedtest-cli from the command line and get results. I can see both executables in /usr/bin, which leads me to think that the issue is with Ookla’s instructions on their website. However, I’m not clear if this will actually work.

It also results in error messages when running sudo apt-get update due to the lack of a release file.

speedtest-cli’s package is based on raspberrypi.org

apt-cache policy speedtest-cli
speedtest-cli:
  Installed: (none)
  Candidate: 2.0.2-1+deb10u2
  Version table:
     2.0.2-1+deb10u2 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages

and according to the description of the Ookla Speedtest binding ( first post ) does not work ( which I did not check ):

Thanks, I didn’t know how to check that. Weird that Ookla hasn’t fixed their repository, as it’s been like this for a long time.

Is it possible to add a Item with the TimeStamp of the last SpeedTest run?
I tried to implement it with a manual item (not connected to the binding) but i don’t get it working

Greetings Alex

Hi Alex, good idea. I will consider this during the next update. It will be only available for openHAB 4, as there is no maintenance of this binding for openHAB 3.
As workaround you could use a timestamp-update profile e.g. on the resultUrl channel:

Kind regards
michael

1 Like

Is this binding working with OH4?
For me unfortunately not. The channels are missing :frowning:


2023-08-19 01:01:45.501 [WARN ] [core.thing.internal.ThingManagerImpl] - Channel types or config descriptions for thing 'speedtest:speedtest:f55a0f0b6e' are missing in the respective registry for more than 120s. In case it does not happen immediately after an upgrade, it should be fixed in the binding.
2023-08-19 01:01:45.504 [WARN ] [core.thing.internal.ThingManagerImpl] - Failed to normalize configuration for thing 'speedtest:speedtest:f55a0f0b6e': {thing/channel=Type description speedtest:ping_jitter for speedtest:speedtest:f55a0f0b6e:ping_jitter not found, although we checked the presence before.}

Have you tried deleting and recreating the thing?

Since OH4, the binding is officially supported. Please uninstall the marketplace addon that was used in OH3 and install the new official binding.

Thank you! Didn‘t know that.

Removing the .jar and installing via gui fixed it.

Only problem is now the unit for the ping.
Before the update the ping was 12,4 (which is correct) now it is 0,0124.
How can I set the unit to the correct one? What do I need to add at the meta data unit for the item?

Checked again the way how the binding is implemented. It is updating the Channel using a QuantityType. Means the only configration that your ping item needs is a proper State Description, i.e. pattern="%.2f ms if you would like to show the value in ms instead of s.

Is there any chance for implementing two functionalities?

  • URL to .png image of last measurement
  • Timestamp of last measurement

I know it can be done somehow with the rules but since it is official binding than maybe it would be worth considering to add such options.

Timestamp is already implemented, but not yet merged. I guess it will come for OH4.1.0.

.png is a good idea. I will have a look.

1 Like

Result Image is also working. I’m going to prepare a PR soon …

2 Likes

Thats really great. Thanks for hard work.

Hi Mike,
could it be that the marketplace version 3.4.0 is broken?
Because it only has two channels (ISP/Server).
My speedtest VM is still running with oH 3.4.0 because i hadn´t the time to update the underlying debian for oH 4.

Thanks!

Hi
I’ve installed the speedtest packages (linux) and i can run them from the command line but the -f parameter is not supported. I get the following :

speedtest: error: unrecognized arguments: -f json

I switched logging on in the OpenHab console and I see this

The command to be executed will be ‘[sh, -c, /usr/bin/speedtest -f json --accept-license --accept-gdpr]’

Is there a way of altering the command line parameters so that they conform to the following

usage: speedtest [-h] [–no-download] [–no-upload] [–single] [–bytes] [–share]
[–simple] [–csv] [–csv-delimiter CSV_DELIMITER] [–csv-header]
[–json] [–list] [–server SERVER] [–exclude EXCLUDE] [–mini MINI]
[–source SOURCE] [–timeout TIMEOUT] [–secure] [–no-pre-allocate]
[–version]

Worth noting that --version gives me this result

speedtest-cli 2.1.3
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]

update -
I changed the execPath to

execPath="/usr/bin/speedtest --json # "

Now I see this in the logs

2023-09-01 10:06:54.309 [DEBUG] [.speedtest.internal.SpeedtestHandler] - Getting Speed Measurement
2023-09-01 10:06:54.309 [DEBUG] [.speedtest.internal.SpeedtestHandler] - Passing to shell for parsing command.
2023-09-01 10:06:54.310 [DEBUG] [.speedtest.internal.SpeedtestHandler] - OS: *NIX (Linux)
2023-09-01 10:06:54.310 [DEBUG] [.speedtest.internal.SpeedtestHandler] - The command to be executed will be ‘[sh, -c, /usr/bin/speedtest --json # -f json --accept-license --accept-gdpr]’
2023-09-01 10:07:15.809 [DEBUG] [.speedtest.internal.SpeedtestHandler] - Exec [OUTPUT]: ‘{“download”: 72748961.65868178, “upload”: 18890166.080415953, “ping”: 10.081, “server”: {“url”: “http://speed-test.ukservers.com:8080/speedtest/upload.php”, “lat”: “51.xxx”, “lon”: “-0.xxx”, “name”: “London”, “country”: “United Kingdom”, “cc”: “GB”, “sponsor”: “UK Dedicated Servers”, “id”: “30376”, “host”: “speed-test.ukservers.com:8080”, “d”: 50.02348021953681, “latency”: 10.081}, “timestamp”: “2023-09-01T09:06:54.681003Z”, “bytes_sent”: 23846912, “bytes_received”: 91119156, “share”: null, “client”: {“ip”: “xxx.xxx.xxx.xxx”, “lat”: “51.xxxx”, “lon”: “0.xxxx”, “isp”: “xxx”, “isprating”: “3.7”, “rating”: “0”, “ispdlavg”: “0”, “ispulavg”: “0”, “loggedin”: “0”, “country”: “GB”}}’
2023-09-01 10:07:15.883 [DEBUG] [.speedtest.internal.SpeedtestHandler] - Exception: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was NUMBER at line 1 column 14 path $.download

So it looks like it’s running but then can’t process the json output

Hi Michael,

Sorry, but I fear the issue is on your end:
Speedtest oh3.4.0 was not updated since 9 month, and nobody else is reporting that issue:

Did you re-add the thing?
Any error-logs to share?

thanks and kind regards
michael

You have the wrong version of speedtest installed.

It seems that you installed a Python version of speedtest-cli.
What you need is the Ookla Speedtest executable (see README):

Re-adding working, but some of the channels have new IDs.
Like downloadBandwidth instead of download_bandwidth.
When did the definition changed?