Speedtest-cli Internet Up-/Downlink Measurement Integration


(Yancy M) #21

I am running OH on Windows 10. The original file is being copied off the internet using wget, to a temp name. Then I copy that file using a batch file with the standard copy command to the well-known name that I’m referring to in my sitemap. If OH is shutdown, I can copy over my image without any issues. When OH launches, if I do not go to the UI page that shows the image, I can copy over the image file without issue. As soon as I go to the UI page where I show the image I am no longer able to copy over the file. Even if I exit that page and go to other pages, it is still locked.

I have used sysinternals Process Explorer to see what app has the file open and it shows java.exe.

I’m doing a similar file overwrite with my BlueIris app for cameras, to multiple static camera images. They get refreshed without any issues, even after I’ve viewed them in the oh UI.

I’m running OH 1.8.1

Thanks.


(farhan) #22

Yes, i’m on Windows too

made a batch file that download the image using curl, and then copy it to /webapps/images/result.png

failed with this message:

The requested operation cannot be performed on a file with a user-mapped section open


(Yancy M) #23

Same message I get as well. I even created a scheduled task to run at admin privilege and it still doesn’t work. For some reason Java is keeping some image files open/locked and not others.


(John Cocula) #24

I wonder if this is a new issue with files being left open, and if it is only on Windows? These issues seem to appear more often on Windows for some reason.


(Dominic Spatz) #26

Is it possible to get the IP with the Speedtest application?
I did it with an external script.
What i want to do is: get the Ip and Display it as a Link in OpenHAB


( ) #27

Hey Dominic,
it’s not possible with peedtest-cli.
You can however use any of the many services which will tell you your external IP. Take this as an example: http://myexternalip.com/#howto
I didn’t try but something similar to this should do the trick:

   var String ip = executeCommandLine("/usr/bin/curl@@http://myexternalip.com/raw", 3*1000)

You can in the next step show it as a sitemap element.

Why do you want the ip as a link? I don’t think that’s even possible but it also doesn’t make sense. You probably want the link to open openhab or some other service at your home? You should really consider using a dynamic dns service like https://www.noip.com

Best!


(Dominic Spatz) #28

Of course i am using a dyndns service. But i want to access the ip in order to use a certain feature.
Would be great if OH2.x allows hyperlinks within a sitemap.


( ) #29

Okay that’s quite off-topic…
I would second that, not because of hyperlinks but more in general. Sitemaps are rather strict. There are a few basic elements I would wish for in sitemaps. Text inputs or drop-down menus, visual separators, non-changable switches, etc. etc.
Another extreme would be to allow user-defined html+css but that’s not an option because of the compatibility to apps and other integrations.
A wider set of supported sitemap elements would be great. I would be interesting to hear @Kai’s opinion on that, especially looking at OH2.


(farhan) #30

actually if you omit “–simple” from speedtest-cli, the result will also lists your ISP and IP address.

IP = cat result.txt | tr "()" "\n" | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}"


(Maurits) #31

Question, when I execute the rule it all works when I // the following line:

postUpdate(SpeedtestResultDate, new DateTimeType(now.toCalendar(null)))

The designer gives the following error messages:

Multiple markers at this line

  • Couldn’t resolve reference to JvmConstructor ‘DateTimeType’.
  • Couldn’t resolve reference to JvmIdentifiableElement ‘now’.
  • Couldn’t resolve reference to JvmIdentifiableElement ‘toCalendar’.

I tried everything, but didn’t seem to be able to solve it. Somebody has an idea?


(Maurits) #32

I discovered the solution myself today, at the top of the .rules file you need to import the following:

import org.openhab.core.library.types.*
import java.util.Date

Then it works fine.

@ThomDietrich, maybe you can add this to the code in your message.


(John Cocula) #33

To get a DateTimeType that refers to the current moment, the no-arg constructor should be all you need: new DateTimeType().


(Dpfaffenbauer) #34

works great, thank you :slight_smile:


(Maurits) #35

Hi Watou, thanks for your answer, however in my file it doesn’t seem to work. I have the following:

postUpdate(SpeedtestResultDate, new DateTimeType())

But if I use this, the rules stops at Executing test

In the end it works with the importing of the two libraries.

Thanks again.


(John Cocula) #36

Try

SpeedtestResultDate.postUpdate(new DateTimeType())

And under openHAB 1.x, you do need this import for the above line:

import org.openhab.core.library.types.DateTimeType

( ) #37

Hey Maurits,
you are totally right, I missed to mention the imports.
I can not check/test my setup right now but in my files I have the following imports:

    import org.openhab.core.library.types.*
    import org.joda.time.*

I’ll check which are really needed later today and update the code. Thanks for your input!


(Maurits) #38

Hi Watou,

Your solution works like a charm, with the smallest amount of importations.

@ThomDietrich, the above solution from Watou works perfectly.

Thanks


(Jeff Smeker) #39

Trying to get this up and running, and running into trouble right from the start (running Ubuntu). I get to:

sudo easy_install speedtest-cli

which fails with the error:

Searching for speedtest-cli
Reading https://pypi.python.org/simple/speedtest-cli/
Download error on https://pypi.python.org/simple/speedtest-cli/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) -- Some packages may not be found!
Couldn't find index page for 'speedtest-cli' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) -- Some packages may not be found!
No local packages or download links found for speedtest-cli
error: Could not find suitable distribution for Requirement.parse('speedtest-cli')

Any ideas why this may happen? Thanks!


( ) #40

This is an easy_install related problem. Please try the pip installation way or one of the others listed here: https://github.com/sivel/speedtest-cli

Related to your problem, your certificate cache seems to be outdated. Have a look at http://stackoverflow.com/questions/21265616/python-easy-install-fails-with-ssl-certificate-error-for-all-packages


( ) #41

“Try” is always a good solution with openhab ^^ There are still some inconsistencies I guess.
Sadly the posting is too old to edit. I’ll at least update the wiki article to only need the one import.
Thanks for your help.

Can somebody reading this by any chance edit the first posting to only show the screenshot and the wiki Link?

You can find the newest version of this function here: https://github.com/openhab/openhab/wiki/speedtest-cli-integration