Speedtest-cli Internet Up-/Downlink Measurement Integration

(Muplex) #123

I didn’t understand the line
I found the file /usr/bin/speedtest-cli on these path but what is the meaning of @@???

If I type speedtest-cli@@–simple inside the /usr/bin/ folder the bash result is "Command not found "

speedtest-cli --simple works fine in SSH connection…

(Kuba Wolanin) #124

@Muplex, executeCommandLine requires to replace each space character with @@.

(Muplex) #125

Thank @kubawolanin 4 the reply…

I found a difference to make it work these add on on my setup.
The modification is

if (speedtestCliOutput.startsWith("Ping") && speedtestCliOutput.endsWith("Mbits/s"))

instead of

if (speedtestCliOutput.startsWith("Ping") && speedtestCliOutput.endsWith("Mbit/s"))

a little S make the difference

(Michael Heckmann) #126

thanks @ThomDietrich for this great tutorial.
Installing it was really easy, but when executing it gives me an error:

2018-01-04 16:08:11.108 [INFO ] [arthome.model.script.speedtest.rules] - --> speedtest executed...
2018-01-04 16:10:11.272 [ERROR] [arthome.model.script.speedtest.rules] - --> speedtest failed. Output:

That means there is no output.
On the other hand executing the speedtest-cli --simple on the command line shows:
I’m using speedtest 1.0.7

pine64@pine64:/usr/local/bin$ speedtest-cli --simple
Ping: 38.945 ms
Download: 9.81 Mbit/s
Upload: 3.94 Mbit/s

That confuses me.
Any ideas?
Thanks, Michael

( ) #127

@Muplex I just did the test. Both the version 1.0.6 and the latest 1.0.7 produce “MBit/s” on my system. Really strange.

@Mitch77 Seems like the variable speedtestCliOutput is empty, that shouldn’t be. You need to debug your rule. First check if the absolute path /usr/local/bin/speedtest-cli is correct. Next check if you can execute the command as user openhab. If so did you install the Exec binding?
You’ll find that it’s often easy to debug on your own.

(moberlin8) #128

FWIW: I can confirm I get “Mbits/s”

$ /usr/bin/speedtest-cli --version

Openhab is running on a raspberry Pi 3

$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 8.0 (jessie)
Release:        8.0
Codename:       jessie

(Michael Heckmann) #129

Ha, at least it was an “easy” one.
After I checked that

sudo -u openhab /usr/local/bin/speedtest-cli --simple

was working, I found that it took quite a long time til the results came. So I tried to extend the timeout. With 5 minutes timeout it’s working now. FTR: I changed the following line in your rule to:

 var String speedtestCliOutput = executeCommandLine("/usr/local/bin/speedtest-cli@@--simple",5*60*1000)

( ) #130

Hui that’s strange! Maybe it’s related to the server used for testing in your area?

(griMA) #131


I read the entire thread, but I am still not aware how my speedtest data is stored in influxdb.
In the provided python script (first post from ThomDietrich), db and ip etc is specified in the script.

Probably it is easy, but I can not see the wood for the trees.

(Jerome Luckenbach) #132

The script just updates the corresponding openHAB Items you have created.
The items then get stored in influxdb with the persistence service, you have configured in openHAB.

(Michael Joos) #133

Did someone else see something like this in the past?

2018-02-13 01:00:12.114 [ERROR] [.eclipse.smarthome.model.script.RULE] - --> speedtest failed. Output:
Cannot retrieve speedtest configuration
ERROR: timed out

This started to happen for me let’s say 1-2 month ago. The funny thing is that manually it just works…100%. I see this error message only with time based rule-start. This is the part of my rule:

rule "Speedtest"
Time cron “0 00 01 * * ?” or // Every day 01:00
Item SpeedtestRerun received command ON
then {

Very strange…Any ideas what causes this error? I’m always on latest snapshot.


(davorf) #134


I’m not sure if this is causing an error you’re having, but you shouldn’t use curly brackets after THEN.
If I’m not mistaken, syntax should be:

Rule "Rule name"

Best regards,

(Michael Joos) #135

Unbelievable that I didn’t see that :flushed:
The rule worked now the last 3 nights…sometimes it’s good that someone else keeps an eye on it!

(Kris K) #136

Anyone know why this suddenly broke?

kris@OpenHAB:~$ speedtest-cli --simple
Cannot retrieve speedtest configuration
ERROR: <urlopen error [Errno -2] Name or service not known>

(Crispin) #137

Mine still working OK.

(Kris K) #138

How does this script work? I cant actually see where/how it does the logic and what website/url it tries to hit…

(Steven Reimer) #139

This is all working great for me except the chart which is blank. I am using MySQL persistence and can see my ISP data being added in the tables. I’m not sure where I’m going wrong

Here is the sitemap section

Text item=SpeedtestSummary {
  Frame label="Results" {
	Text item=SpeedtestResultDown
	Text item=SpeedtestResultUp
	Text item=SpeedtestResultPing
  Frame label="Control" {
	Text item=SpeedtestResultDate
	Text item=SpeedtestRunning label="Speedtest [%s]" visibility=[SpeedtestRunning != "-"]
	Switch item=SpeedtestRerun mappings=[ON="Start"]
  Frame label="Statistics" {
		Switch item=chart_period label="Speed Graph" mappings=[0="Day", 1="Week", 2="Month", 3="Year"]
		Chart item=gSpeedtest period=D refresh=30000 visibility=[chart_period==0, chart_period=="Uninitialized"]
		Chart item=gSpeedtest period=W refresh=30000 visibility=[chart_period==1]
		Chart item=gSpeedtest period=M refresh=30000 visibility=[chart_period==2]
		Chart item=gSpeedtest period=Y refresh=30000 visibility=[chart_period==3]


And here are my items

Group gSpeedtest <"network-icon"> (Whg)

String      SpeedtestSummary        "Speedtest [%s]"             <"speedtest_network">       (gSpeedtest)
Number      SpeedtestResultPing     "Ping [%.3f ms]"             <"speedtest_next5">         (gSpeedtest)
Number      SpeedtestResultDown     "Downlink [%.2f Mbit/s]"     <"speedtest_download">      (gSpeedtest)
Number      SpeedtestResultUp       "Uplink [%.2f Mbit/s]"       <"speedtest_upload">        (gSpeedtest)
String      SpeedtestRunning        "Speedtest running ... [%s]" <"speedtest_new">           (gSpeedtest)
Switch      SpeedtestRerun          "Start manually"             <"speedtest_reload2">       (gSpeedtest)
DateTime    SpeedtestResultDate     "Last executed [%1$td.%1$tm.%1$tY, %1$tH:%1$tM]"   <"speedtest_problem4">      (gSpeedtest)

Number chart_period "Graph Period"

Everything is basically verbatim right out of the example. Any idea what I am missing?

(Danny mullen) #140

How did you build the chart? The example uses influxdb vs MySQL. Seems like the chart is not pointing at the data possibly?

I had the issue in grafana, then realized my query was wrong. If using grafana use the web interface and make sure the query sees data.

(Cesare Arigliano) #143

Hello… how to make speedtest working on a docker installation of openhab ?

(Rich Koshak) #144

Build a custom Docker Image that includes the software necessary to run speedtest-cli.