OH3 and Speedtest Ookla

You’ll have to add speedtest to the Docker container by building a custom image or adding a script to run before openHAB does when the container starts up to install it. See Docker Hub

You can set up a file and web server (maybe even FTP) on a machine on your LAN and set up a Network binding speedtest Thing using that internal URL. The network binding can also be configured with a short ping time for online/offline tracking. But in general there are lots of way better tools for monitoring this sort of thing than openHAB.

Sorry, I’m sure I got it wrong. I would like to use “Speedtest Ookla” in OH 3 as an alternative to network binding.

That makes literally no sense! :wink:
Please check the docs, what the network binding does:

Ookla speedtest measures your internet connection speed (Jitter, Ping, Upload Speed, Download Speed, lost packages, …). Two completely differnet things.

I have already added a Docker container “speedtest” (henrywhitaker3 / speedtest-tracker). How do I have to configure openhab 3.1 to take over the values? I need help configuring in OH3.

@sihui posted two pretty thorough tutorials above.

Are these tutorials suitable for use in Docker? How are they integrated? I am not an expert!

Have you read them? Have you tried them out? Have you done any basic reading on what Docker and containers are and how they work? If you are running OH in Docker, you should understand what Docker and containers are and how they work well enough to be able to read a tutorial like the above and know whether you can use it.

You can’t be successful with OH if you don’t have a basic understanding of the technologies you are using.

As for how are they integrated? That’s the whole point of a tutorial. It tells you how to do it.

1 Like

I’ve even bought various books in the past few months. Nevertheless, it can happen that you still need help. I thought there was a place here to ask.

All right, thank you gentlemen for their help.

no need for those bitter words.
If you scroll through this forum there’s only people helping other people out. But those helping need something to work with - and as we all don’t get a single dime for helping we expect at least a bit of own effort. We are not here to built you your solution at will. If you come here with concrete questions we’re all happy to help. We provided you with a bunch of information and still you didn’t seem to read it but eager to have your problem solved by us.

Dear Thomas,

so one can be mistaken. I read my way through this topic here very well (even all night long). Otherwise I would hardly know that the file org.openhab.binding.speedtest-3.1.0-SNAPSHOT.jar is now version 0.5. I was also impressed by the efforts of the users rpwong, muelli1967, Rgroll and bhomeyer. However, Speedtest Ookla still does not work. I think, however, that I won’t ask any more questions in this forum, as I must first prove that I have searched sufficiently. Then I prefer to do without. I am very upset about the last post from Rich Koshak -Foundation member- because it is simply not true!
I’ve only been involved with Openhab for a year. Nevertheless, I can occasionally give help to other users in the German forum and don’t ask whether they have read enough beforehand.
I wish you all the best!

What specifically is not true from my post? First I asked some questions and they were not rhetorical questions. Did you actually look at those tutorials? Do you understand how Docker container work?

And yes it is absolutely true that you have to have at least a basic understanding of the technologies you are working with in order to be successful with openHAB. If you are going to use a less common configuration such as running openHAB on Docker it’s even more important to have that understanding.

Nowhere have you made any indication that you have even read those tutorials and given them a try. If you had you would have learned that indeed, those tutorials do work with Docker once you have speedtest installed in the container. It’s all done through the Exec binding.

Or, if you did try and it didn’t work for you, you’ve provided zero details about what you have actually tried to do and what the problem might be. From our perspective you want us to just tell you how to do it. But there are already two great and thorough posts sihui provided that do just that so why do we have to take the time to write it up yet again here?

There are two conventions many/most of the helpers on this forum follow:

  1. If you don’t tell us we have no choice but to assume you’ve not even tired.

  2. If you’ve not even tried, we’re not going to do it for you.

You may have spent hours look at something and trying things out but there is no evidence of that here. From my perspective all I see is a refusal to even go and look at the tutorials until someone here tells you to. And then what happens at the next tutorial? Do we have to tell you that it applies to Docker too? And the next and the next?

1 Like

I already wrote that I don’t have to prove in order to get help from you. It is the way it is and there won’t be a next tutorial for me either. I have been following their contributions for a long time and have great respect for their expertise. But there is another remark that I would never have made if I were you. I do not understand their attitude. Again: there will be no more questions from me because I first have to prove that I have already read it.

So simply saying “I read x and tried y and don’t understand z” is too much of a burden? That shows a huge sense of entitlement and complete lack of respect for the time we donate helping people on this forum. You are basically saying “I don’t have to help those people on the forum answer my question in the least amount of time so they can use the rest of their time helping others. I demand and deserve they answer my question with the least amount of effort on my part because my time is more valuable than theirs.”

And I’m certain you think I’m the rude one here.

I’d have dropped this before and will drop it now, but I want to make this clear to future readers of this thread.

When you do not help us help you be telling us specifically what you have tried and specifically what you don’t understand it’s a waste of both your and our time. We don’t ask this of you to prove your worthiness or something like that. It’s just a common curtesy and a sign that you respect the time people donate in trying to help. The more specific the question the less time usually it takes to answer it. The more details provided the less time it takes to answer it. The more you tell us about what you’ve already tried the less time it takes to answer it. If asked follow up questions, answer them.

1 Like

This answer cannot be beaten in arrogance. I’m going to make my thesis now: You can’t help me because it’s too special. You have already noticed that it is a bit more special. If I don’t give you enough to help, why don’t you hold back?
As for your advice to future readers, I’d like to point out that you might want people to use an alternative to OH so as not to be treated like a rude person here. I do not want to go into every allegation made by them. Just this much: you have disappointed me and maybe I’ll take a look at something else.

I’m sorry, Rich is one of the most active and as it happens the most liked user here in the forum. I’m afraid you are the arrogant one.
Please calm down a bit and take a step back and read again through this thread. You gave (and give) not the impression to have

  1. read the sources we gave you
  2. told us what you already tried - and failed to do
  3. told us, what obstacles you face

but: you have told us

  1. to solve your problem nevertheless
  2. even doubled down on your position - after being told so from multiple users here on the forum

:blush:

1 Like

You can close this topic

FYI there is a new binding getting reviewed here and the author supplied a jar file.

[speedtest] Binding for Ookla’s Speedtest - Initial contribution by bigbasec · Pull Request #9913 · openhab/openhab-addons (github.com)

Thank you, I have already found this version and saved it in the “Addons” folder. A recommended rule is installed to trigger the query. But it doesn’t work. (The Exec binding is also installed.)
I actually always take a lot of time when problems arise - that was also the case this time. Since I can’t get any further, I will forego the new binding and speed test.

Hi,
i want to share my current solution for the ookla docker container integration (based on Speedtest CLI by Ookla - Internet Up-/Downlink Measurement Integration):

  • I’m using the ookla docker image tamasboros/ookla-speedtest that is
  • writing the json output to /opt/openhab/userdata/tmp/ookla.json, this file is then
  • parsed by the speedtest rule (instead of executing the ookla speedtest and fetching the json like in the original rule). To do so, i added a try-catch block around, reading the file and convert the pretty json to a one-liner with 2 regex. (-> see MODIFICATION START / END)
  • cronjob is running the ookla speedtest container every minute.

speedtest.rules:

// MODIFICATION START
import java.nio.file.Files
import java.nio.file.Paths
// MODIFICATION END

val String ruleId = "Speedtest"
val Number calc = 125000 // Converting from bits to Mbits

rule "Speedtest init"

when

    System started

then

    createTimer(now.plusSeconds(195))
    [|
        if(SpeedtestRerun.state == NULL)
        {
            SpeedtestRerun.postUpdate(OFF)
        }

        if(SpeedtestRunning.state == NULL)
        {
            SpeedtestRunning.postUpdate("-")
        }

        if(SpeedtestSummary.state == NULL || SpeedtestSummary.state == "")
        {
            SpeedtestSummary.postUpdate("⁉ (unbekannt)")
        }
    ]

end

rule "Speedtest"

when

    Time cron "0 0/15 * * * ?" or
    Item SpeedtestRerun changed from OFF to ON or
    Item SpeedtestRerun received command ON

then
    //logInfo(ruleId, "--> speedtest executed...")
    SpeedtestRunning.postUpdate("Messung läuft...")

    // execute the script, you may have to change the path depending on your system
    // Please use -f json and not -f json-pretty
    //val speedtestExecute = "speedtest --accept-gdpr --accept-license -f json"
	var String speedtestCliOutput;
	// MODIFICATION START
	try {
        speedtestCliOutput = new String(Files.readAllBytes(Paths.get("/openhab/userdata/tmp/ookla.json")))
		speedtestCliOutput = speedtestCliOutput.replaceAll("\\s+", "").replaceAll("\\r\\n+","")
		// MODIFICATION END

		// for debugging:
		// var String speedtestCliOutput = "Ping: 43.32 ms\nDownload: 21.64 Mbit/s\nUpload: 4.27 Mbit/s"
		logInfo(ruleId, "--> speedtest output after readfile:\n" + speedtestCliOutput + "\n\n")
		SpeedtestRunning.postUpdate("Datenauswertung...")

		// starts off with a fairly simple error check, should be enough to catch all problems I can think of
		if (speedtestCliOutput.startsWith("{\"type\":\"result\",") && speedtestCliOutput.endsWith("}}"))
		{
			var ping = Float::parseFloat(transform("JSONPATH", "$.ping.latency", speedtestCliOutput))
			SpeedtestResultPing.postUpdate(ping)

			var float down = Float::parseFloat(transform("JSONPATH", "$.download.bandwidth", speedtestCliOutput))
			down = (down / calc)
			SpeedtestResultDown.postUpdate(down)

			var float up = Float::parseFloat(transform("JSONPATH", "$.upload.bandwidth", speedtestCliOutput))
			up = (up / calc)
			SpeedtestResultUp.postUpdate(up)

			var String url = transform("JSONPATH", "$.result.url", speedtestCliOutput)
			val img = url + ".png"
			SpeedtestResultImage.postUpdate(img)

			SpeedtestSummary.postUpdate(String::format("ᐁ  %.1f Mbit/s  ᐃ %.1f Mbit/s (%.0f ms)", down, up, ping))

			SpeedtestRunning.postUpdate("-")

			// update timestamp for last execution
			val DateTimeType ResultDate = DateTimeType.valueOf(transform("JSONPATH", "$.timestamp", speedtestCliOutput))
			SpeedtestResultDate.postUpdate(ResultDate)
		}
		else
		{
			SpeedtestResultPing.postUpdate(0)
			SpeedtestResultDown.postUpdate(0)
			SpeedtestResultUp.postUpdate(0)
			SpeedtestSummary.postUpdate("(unbekannt)")
			SpeedtestRunning.postUpdate("Fehler")

			logError(ruleId, "--> speedtest failed. Output:\n" + speedtestCliOutput + "\n\n")
		}

		SpeedtestRerun.postUpdate(OFF)
		
	// MODIFICATION START	
	} catch (IOException e){
		SpeedtestResultPing.postUpdate(0)
		SpeedtestResultDown.postUpdate(0)
		SpeedtestResultUp.postUpdate(0)
		SpeedtestSummary.postUpdate("(unbekannt)")
		SpeedtestRunning.postUpdate("File Error")

		logError(ruleId, "--> speedtest failed. Output:\nookla output reading failed!\n\n")
		
	}
        // MODIFICATION END
end

/etc/cron.d/docker
* * * * * docker /home/docker/docker_ookla.sh

/home/docker/docker_ookla.sh

docker run --rm --name ookla tamasboros/ookla-speedtest > /opt/openhab/userdata/tmp/ookla.json

I’m quite sure this is not the most beautiful solution, but due to lack of time my only one working :wink:

1 Like