Page 1 of 1

Re: Speed-test

Posted: Friday 12 January 2018 12:33
by leonmoonen
I have a similar script running based on the package speedtest-cli (sudo apt-get install speedtest-cli) but considering the first line of your output, this is not important for issue you are experiencing, your script obtains valid speedtest values but fails in three curl lines at the end... (I've double-checked the parsing of the json with cut and tr and that seems ok)

Some questions:
* In the script you're actually using, did you set the variable domoip to the correct IP address for your domoticz machine instead of the xx.xx.xxx.xxx?
* and 8080 is the port you are using?
* Do you have some kind of password/authorization set up for the domoticz interface?

Re: Speed-test

Posted: Saturday 13 January 2018 11:20
by leonmoonen
Hi,

Can you explain in more detail what you mean with "And now i don't get errors, i get only the values what must be. But now i want to see it in domoticz and that is also a problem for me."
- where do you get these values? on the command line? The sensors show up under the Utility menu for me
- have you set up the virtual sensors for ping, downstream and upstream in Domoticz? and are their idx values correcty set up in the script (I assume so, but just checking, as I was a bit surprised by the gap in the numbers)
- how are you (intending) to run the script? automatically from a cron job? have you set that up?

As for step-by-step instructions, the wiki has a page discussing the set-up where the script is triggered by a (virtual) switch in the Domoticz GUI: https://www.domoticz.com/wiki/Bash_-_Sp ... monitoring
It uses a different package to access speedtest but you can ignore that, as we know you get the right values; you can also ignore the difference in how the variables get their value (sed vs cut/tr in your case).

If you follow hat guide w.r.t. setting up the virtual sensors and have adapted your script with the correct idx values it "should" work. If it still doesn't, pls have a look in the domoticz log (6th entry in the setup menu) immediately after manually running the script. Maybe that will give us a clue.

Once we have things running manually we can go over the cron setup (if needed).

cheers,
Leon

Re: Speed-test

Posted: Saturday 13 January 2018 16:04
by leonmoonen
Hi,
pascalbianca wrote: Saturday 13 January 2018 14:29 - [...] I don't see sensors in the utility menu
-Yes the virtual sensors for ping, downstream and upstream did i make in Domoticz [...]
The fact that you do not see the sensors (even with a value of 0) in the Utility tab makes me think something may have gone wrong with the virtual sensor setup. Let's check your configuration:
(1) If you look at Setup > Hardware, do you have a dummy entry that looks like this (possibly with a different idx):
Screen Shot 2018-01-13 at 15.35.07.png
Screen Shot 2018-01-13 at 15.35.07.png (22.65 KiB) Viewed 2584 times
If you don't have this, pls post a screen shot of your hardware interfaces.
(2) If you look at Setup > Devices (and search on "Custom"), do you have custom sensors that looks like this (likely with a different idx, each of these virtual sensors was made by pressing the "Create Virtual Sensor" button for the Dummy interface in Hardware and setting the Sensor Type to Custom Sensor):
Screen Shot 2018-01-13 at 15.35.55.png
Screen Shot 2018-01-13 at 15.35.55.png (51.08 KiB) Viewed 2584 times
If you don't have this, pls post a screen shot of your devices, limited by a search on "Sensor". Also, it would help if you can show us the lines for the devices with idx 57, 98 and 99 (the ones you have configured in your script).

I don't understand why you get the script error in the Domoticz log if you are using cron, or have you also made the "broadband switch" to execute the script? (I've never tried that part, but I'll add one to see how this works). One common issue with running scripts from with Domoticz are permissions. I would consider a `chmod 755 /home/pi/domotics/speedtest.sh` (or alternatively `chmod a+rx /home/pi/domotics/speedtest.sh`) so that all users can read and execute the script.

[update]
The "Error executing script command"-error can be solved by adding the line "exit 0" to the end of your script. Without that line an exit code different than 0 is returned, which is interpreted by Domoticz as an error.

cheers,
Leon

Re: Speed-test

Posted: Monday 15 January 2018 2:08
by leonmoonen
Hi,

Glad to hear things work OK now :)

Just for your information: the script location should not matter, I typed that one from the top of my head but I now realize that placing things in the main domoticz directory may mean that they get deleted when you do an upgrade (I actually keep them in the directory /home/pi/scripts to avoid such issues).

Also, repeated writing of the speedtest.txt file is not so good for the SD card and increases changes for corruption. I currently have the same solution, but I'll investigate some alternatives. One option is to set up a RAM drive and write the temporary file there (see http://www.domoticz.com/wiki/Setting_up ... spberry_Pi). However, I think it should also be possible to capture the whole speedtest output in a shell variable and instead of 'cat'-ing the file you could then 'echo' that variable...

[update] After some tweaking, the following code works

Code: Select all

#version that does not write a tempfile to disk
speedtest=$(speedtest-cli --simple)
png=$(echo "$speedtest" | sed -ne 's/^Ping: \([0-9]*\.[0-9]*\).*/\1/p')
download=$(echo "$speedtest" | sed -ne 's/^Download: \([0-9]*\.[0-9]*\).*/\1/p')
upload=$(echo "$speedtest" | sed -ne 's/^Upload: \([0-9]*\.[0-9]*\).*/\1/p')
cheers,
Leon