I was having some troubles with my internet connection and couldn't figure out where they were coming from. I really like the graphing functionality of domoticz and I have implemented a script that notifies me with Telegram, so I wanted to monitor my download speed with domoticz, thought I'd share:
1. Install speedtest
Code: Select all
sudo apt-get install speedtest-cli
3. Create a script (I called it st2domo.sh) with:
Code: Select all
#!/bin/bash
#setup
host=xxx.xxx.xxx.xxx
port=xxxx
username=xxx
password=xxx
pingidx=xxx
downloadidx=xxx
uploadidx=xxx
# no need to edit
speedtest-cli --simple > output.txt
ping=$(cat output.txt | sed -ne 's/^Ping: \([0-9]*\.[0-9]*\).*/\1/p')
download=$(cat output.txt | sed -ne 's/^Download: \([0-9]*\.[0-9]*\).*/\1/p')
upload=$(cat output.txt | sed -ne 's/^Upload: \([0-9]*\.[0-9]*\).*/\1/p')
#output if you run it manually
echo "ping = $ping ms"
echo "download = $download Mbps"
echo "upload = $upload Mbps"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command¶m=udevice&idx=$pingidx&svalue=$ping"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command¶m=udevice&idx=$downloadidx&svalue=$download"
curl -s -i -H "Accept: application/json" "http://$username:$password@$host:$port/json.htm?type=command¶m=udevice&idx=$uploadidx&svalue=$upload"
host = your domoticz server (e.g. localhost or 192.168.x.x)
port = your domoticz port (e.g. 8080)
username = your domoticz username
password = your domoticz password
pingidx = the idx of the virtual sensor for accepting the ping-value
downloadidx = the idx of the virtual sensor for accepting the download-value
uploadidx = the idx of the virtual sensor for accepting the upload-value
Don't forget to make it executable (I always do):
Code: Select all
chmod +x st2domo.sh
Code: Select all
crontab -e
Code: Select all
@hourly /path/to/scrip/st2domo.sh
And you can do 'useful' stuff with it

Enjoy!