Network binding - speedtest

Hi!
I wanted to try how the speed test works in relation to the network.
In the documentation, in the example there is a line:

String Speedtest_Running "Test running ... [%s]" {channel="network:speedtest:local:isRunning"}

Perhaps this is a typo and should be like this :?

Switch Speedtest_Running "Test running ... [%s]" {channel="network:speedtest:local:isRunning"}

After rebooting openHAB, I get the following warnings:

2019-11-14 16:14:25.481 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '5.5785282448' of item Speedtest_ResultDown with format '%.2f %unit%': Conversion = 'u'
2019-11-14 16:14:25.485 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '5.5785282448' of item Speedtest_ResultDown with format '%.2f %unit%': Conversion = 'u'
2019-11-14 16:14:25.491 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '5.5785282448' of item Speedtest_ResultDown with format '%.2f %unit%': Conversion = 'u'
2019-11-14 16:14:25.493 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '5.5785282448' of item Speedtest_ResultDown with format '%.2f %unit%': Conversion = 'u'
2019-11-14 16:14:25.497 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '5.5785282448' of item Speedtest_ResultDown with format '%.2f %unit%': Conversion = 'u'
2019-11-14 16:14:25.499 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '0.0560459576' of item Speedtest_ResultUp with format '%.2f %unit%': Conversion = 'u'
2019-11-14 16:14:25.509 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '0.0560459576' of item Speedtest_ResultUp with format '%.2f %unit%': Conversion = 'u'
2019-11-14 16:14:25.511 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '0.0560459576' of item Speedtest_ResultUp with format '%.2f %unit%': Conversion = 'u'
2019-11-14 16:14:25.512 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '0.0560459576' of item Speedtest_ResultUp with format '%.2f %unit%': Conversion = 'u'
2019-11-14 16:14:25.514 [WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '0.0560459576' of item Speedtest_ResultUp with format '%.2f %unit%': Conversion = 'u'

they are related to this code from the documentation:

Frame label="Down" {
        Text item=Speedtest_ResultDown
        Chart item=Speedtest_ResultDown period=D refresh=30000 service="influxdb" visibility=[chart_period==0, chart_period=="Non initialisé"]
        Chart item=Speedtest_ResultDown period=W refresh=30000 service="influxdb" visibility=[chart_period==1]
        Chart item=Speedtest_ResultDown period=M refresh=30000 service="influxdb" visibility=[chart_period==2]
        Chart item=Speedtest_ResultDown period=Y refresh=30000 service="influxdb" visibility=[chart_period==3]
}

Frame label="Up" {
        Text item=Speedtest_ResultUp
        Chart item=Speedtest_ResultUp period=D refresh=30000 service="influxdb" visibility=[chart_period==0, chart_period=="Non initialisé"]
        Chart item=Speedtest_ResultUp period=W refresh=30000 service="influxdb" visibility=[chart_period==1]
        Chart item=Speedtest_ResultUp period=M refresh=30000 service="influxdb" visibility=[chart_period==2]
        Chart item=Speedtest_ResultUp period=Y refresh=30000 service="influxdb" visibility=[chart_period==3]  
}

What needs to be fixed to get rid of these warnings?
PS It is very inconvenient that the binding returns units of measure, they have one problem :frowning:
Can I somehow abandon the units?
Thanks!

I found this.
so there are no warnings:

        Frame {
                Text item=Speedtest_ResultDown label="Download [%.2f Mbit/s]"
                Chart item=Speedtest_ResultDown label="[%.2f]" period=D refresh=30000 service="influxdb" visibility=[chart_period==0, chart_period=="Non initialisé"]
                Chart item=Speedtest_ResultDown label="[%.2f]" period=W refresh=30000 service="influxdb" visibility=[chart_period==1]
                Chart item=Speedtest_ResultDown label="[%.2f]" period=M refresh=30000 service="influxdb" visibility=[chart_period==2]
                Chart item=Speedtest_ResultDown label="[%.2f]" period=Y refresh=30000 service="influxdb" visibility=[chart_period==3]
        }

        Frame {
                Text item=Speedtest_ResultUp label="Upload [%.2f Mbit/s]"
                Chart item=Speedtest_ResultUp label="[%.2f]" period=D refresh=30000 service="influxdb" visibility=[chart_period==0, chart_period=="Non initialisé"]
                Chart item=Speedtest_ResultUp label="[%.2f]" period=W refresh=30000 service="influxdb" visibility=[chart_period==1]
                Chart item=Speedtest_ResultUp label="[%.2f]" period=M refresh=30000 service="influxdb" visibility=[chart_period==2]
                Chart item=Speedtest_ResultUp label="[%.2f]" period=Y refresh=30000 service="influxdb" visibility=[chart_period==3]  
        }

But this is more like a crutch.
Is this right to do?

Please post your item configuration for Speedtest_ResultDown and Speedtest_ResultUp.
You only posted Speedtest_Running which is not the problem.

All unchanged from the documentation.
.things:

Thing network:speedtest:local "SpeedTest 50M" @ "Internet" [initialDelay=5, refreshInterval=60, uploadSize=100000, url="https://bouygues.testdebit.info/", fileName="50M.iso"]

.items:

Group					gNetSpeed																									
String					Speedtest_Result		"testdebit.info [%s]"		<speedtest_network>		(gRestore)						
Switch					Speedtest_Running		"Testing [%s]"				<speedtest_reload2>		(gRestore)					{channel="network:speedtest:local:isRunning"}	
Number:Dimensionless	Speedtest_Progress		"Progress [%d %unit%]"		<speedtest_next5>									{channel="network:speedtest:local:progress"}	
Number:DataTransferRate	Speedtest_ResultDown	"ᐁ Download [%.2f %unit%]"	<speedtest_download>	(gHistory,gNetSpeed)		{channel="network:speedtest:local:rateDown"}	
Number:DataTransferRate	Speedtest_ResultUp		"ᐃ Upload [%.2f %unit%]"	<speedtest_upload>		(gHistory,gNetSpeed)		{channel="network:speedtest:local:rateUp"}	
DateTime				Speedtest_Start			"Running [%1$tH:%1$tM]"		<speedtest_problem4>	(gRestore)					{channel="network:speedtest:local:testStart"}	
DateTime				Speedtest_LUD			"TimeStamp [%1$tH:%1$tM]"	<speedtest_problem4>	(gRestore)					{channel="network:speedtest:local:testEnd"}

Same here and it is working.
But I am using PaperUI Network binding Things, so I guess you should start looking in your things file.

Three of those Items use UoM. The error appears to be having some sort of problem with the %unit% conversion for the Number:DataTransferRate Items, not the Speedtest_Progress Items so I don’t think the link you went to is related to your problem.

It looks like it is not properly interpreting the %unit% which essentially means “the default units”. Instead it is trying to read it as %u as the unit which doesn’t exist.

@sihui, since it’s working for you, can you print what units these two Items are showing on your sitemap or events.log? The DataTransferRate units are not in the docs yet (I opened an Issue for that) and it will be easier if someone to post what they are seeing rather than guessing.

For those of you how got this to work, how did you find a speedtest URL and, more importantly, the name of the file?

I think I was on the wrong track: I just compared the first line from the first post

String Speedtest_Running "Test running ... [%s]"

with the speedtest example from here which I am using:

and that item is almost :sunglasses: the same:

String SpeedtestRunning "Speedtest running ... [%s]" <"speedtest_new"> (gSpeedtest)

Sorry for the confusion.
BTW, the linked speedtest tutorial and example is working great :grinning:

The Network binding now implements the speedtest natively so you don’t have to use the Exec binding and the speedtest-cli any more. Assuming you can figure out how to configure it. But the Network binding requires the Items use UoM and that seems to be the root of the problem.

Hi, All!
Here is what I did:

Number:DataTransferRate Speedtest_ResultDown "Downlink [%.2f %unit%]"  {channel="network:speedtest:local:rateDown"}
Number:DataTransferRate Speedtest_ResultUp "Uplink [%.2f %unit%]" {channel="network:speedtest:local:rateUp"}

Deleted - :DataTransferRate
Replaced - %unit% on Mbit/s

Number Speedtest_ResultDown "Downlink [%.2f Mbit/s]"  {channel="network:speedtest:local:rateDown"}
Number Speedtest_ResultUp "Uplink [%.2f Mbit/s]" {channel="network:speedtest:local:rateUp"}

It works just fine, as I would like!
PS openHAB 2.5.0 Build #1756

Thanks!

1 Like

I assumed that the element is incorrectly declared here, in the documentation it is like a string, I think it should be like a switch.

It works but it doesn’t actually help us figure out if there is a regression bug that has been recently introduced in how the %unit% is handled. You’ve avoided the error by eliminating the UoM but there is still something wrong with the UoM and the %unit% play holder.

Overall this binding works well for me, assuming I stick with the example server and filename given in the binding documentation. BUT, that server’s in France, so not that meaningful for me. I’d like to use a closer server as a better benchmark of my up/down speeds.

I found a list of speedtest servers that (I think?) should allow this sort of traffic:
https://c.speedtest.net/speedtest-servers-static.php

However, the binding also requires a fileName parameter …

Thing network:speedtest:local "SpeedTest" @ "Internet" [refreshInterval=30, uploadSize=8000000, url="https://bouygues.testdebit.info/", filename="50M.iso", initialDelay=5]

But that link above does not give lists of filenames that exist on those speedtest servers for download. I tried not changing the filename:

url="hou.speedtest.sbcglobal.net:8080", filename="50M.iso"

… and that gives a “Error status code 404” errors.

I did a brute force search on this directory with DirBuster, and found that this link:
https://hou.speedtest.sbcglobal.net:8080/download/download
… successfully begins a download of a 10.0 GB file. Cool, that’s good to know, seems like I am getting somewhere!

But since then I have fiddled around with the Thing definition with various permutations of the url and the fileName parameters, and still not yet managed to make it work. I keep getting 404 errors.

Any ideas on how to get this working?

Hej @Dave_Baldwin - I ended up with the same question, when I shifted from speedtest-cli to the binding based network speedtest. The latter shows lower up/download capacity, than speedtest, which seems to automatically choose the closest server (in my case Stockholm)
Could you solve your problem and would you share your solution here?

SOLVED - for any, who runs into this issue

I had succes in using the speedtest.net servers - an overview of servers is on a github here .

My entry to this was though the webpage of an internet provider http://speedtest4.tele2.net/ , which expolians nicely the underlying concept of the speedtest servers.
The network.things file has to point at an anycast server address, which automatically connects to the closest servers, and one can choose from a range of files in different sizes in order to test the connection.
This is my working definition:

Thing network:speedtest:local "SpeedTest 100Mb" [refreshInterval=180, initialDelay=5, url="http://speedtest.tele2.net", fileName="100MB.zip"]

I benchmarked the quite simple solution here against the ookla speedtest webpage (speedtest.net) and the results are the same. There might be caveats with this simple approach, but one avoids extra rules and binding definitions, which a solution with speedtest-cli requires Openhab: speedtest-cli-by-ookla-internet-up-downlink-measurement-integration

Hi all,
Nice binding, very usefull.
For the speedtest, i try the basic thing and it works, but result is very strange as it says my bandwidth is between 2.3 - 2.4Mbit/s (DL).
Problem is that i have a 1Gbits connexion (tested and effective at 950Mbits).
When i do a WGET on the same file with the server, i have more than 900Mbits for bandwidth.
Any clue why the binding speedtest is so slow ?
Thanks

Can you monitor your interface load while the test is performed?
Is the test really that slow or is the shown result wrong?

Thanks for your response.
I monitor the interface all the time, so while the test is performed.
(with iftop for this test)
I really dont understand why network binding/speedtest is so slow …

Hello,
No one else has the same problem ?
Forgot to mention my system : raspberry PI4 (1gb interface) with raspbian.
After a reboot for another reason, my results are now : 40mb/s (DL) 25 mb/s (UL), still far from real bandwidth.

Thank you @mdnx, the suggested server works fine for me and the numbers seem realistic compared to other (web based) speedtests!

However, I got a problem with the returned text from the binding:

2021-02-10 11:14:47.733 [WARN ] [e.internal.SseItemStatesEventBuilder] - Exception while formatting value '91.4568805736 Mbit/s' of item SpeedTest_DownloadRate with format '%d %unit%': d != java.math.BigDecimal

But I don’t really get the problem? The number seems to fit into BigDecimal and there is a space separating it from the unit. What’s failing here?

I fixed the warning in my log with floating pattern like:

%.2f %unit%

Where did you do that? I’m trying to avoid file configs with OH3 now. So I checked the possibilities when linking the item and see that “Number:DataTransferRate” is the preset.

I tried changing this to “String”, but still get the same error. Presumably since the channel in the binding is already defined as such:

So I guess, I have to fall back to create this thing as a Textfile Item to resolve that problem :-/ ?