How to monitor your internet connection with virtual custom sensors
Moderator: leecollings
-
- Posts: 204
- Joined: Thursday 05 September 2013 15:39
- Target OS: Linux
- Domoticz version: LastBeta
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
I created a fairly similar script for a differtent purpose, maybe you guys like it as well: viewtopic.php?f=21&t=14591
homebridge, rfxcom, zwave, nest, applamp, hue, debian, apple, mysensors, netatmo, fibaro, synology, foscam, otherz
Re: How to monitor your internet connection with virtual custom sensors
Hi,
I try to get this working on my Dometicz installed at a Windows 2012-server.
I get Speedtest working and I got python installed and working.
But when running this scrip, I get this error message:
File "speedtest2.sh", line 15
ping=$(cat output.txt | sed -ne 's/^Ping: \([0-9]*\.[0-9]*\).*/\1/p')
^
SyntaxError: invalid syntax
Any idea on what I do wrong?
I try to get this working on my Dometicz installed at a Windows 2012-server.
I get Speedtest working and I got python installed and working.
But when running this scrip, I get this error message:
File "speedtest2.sh", line 15
ping=$(cat output.txt | sed -ne 's/^Ping: \([0-9]*\.[0-9]*\).*/\1/p')
^
SyntaxError: invalid syntax
Any idea on what I do wrong?
-
- Posts: 110
- Joined: Sunday 22 March 2015 7:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Holland
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Place your script and the command you use also here so we can check.johan99 wrote:Hi,
I try to get this working on my Dometicz installed at a Windows 2012-server.
I get Speedtest working and I got python installed and working.
But when running this scrip, I get this error message:
File "speedtest2.sh", line 15
ping=$(cat output.txt | sed -ne 's/^Ping: \([0-9]*\.[0-9]*\).*/\1/p')
^
SyntaxError: invalid syntax
Any idea on what I do wrong?
- gjaa
- Posts: 38
- Joined: Thursday 12 February 2015 6:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
I've made some icons (I don't like the default Icon )
One for up and download (speed)
and one for ping (ping)
One for up and download (speed)
and one for ping (ping)
Re: How to monitor your internet connection with virtual custom sensors
Ok, here is first the code and after that is the command line.mikeoo wrote:Place your script and the command you use also here so we can check.johan99 wrote:Hi,
I try to get this working on my Dometicz installed at a Windows 2012-server.
I get Speedtest working and I got python installed and working.
But when running this scrip, I get this error message:
File "speedtest2.sh", line 15
ping=$(cat output.txt | sed -ne 's/^Ping: \([0-9]*\.[0-9]*\).*/\1/p')
^
SyntaxError: invalid syntax
Any idea on what I do wrong?
Code: Select all
#!/bin/bash
#setup
port=8080
username=xxxx
password=xxxx
host=localhost
pingidx=239
downloadidx=241
uploadidx=240
# 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"
-
- Posts: 110
- Joined: Sunday 22 March 2015 7:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Holland
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Try to change host=localhost to host=ip-adres of domoticz and test if that change something.johan99 wrote:Ok, here is first the code and after that is the command line.mikeoo wrote:Place your script and the command you use also here so we can check.johan99 wrote:Hi,
I try to get this working on my Dometicz installed at a Windows 2012-server.
I get Speedtest working and I got python installed and working.
But when running this scrip, I get this error message:
File "speedtest2.sh", line 15
ping=$(cat output.txt | sed -ne 's/^Ping: \([0-9]*\.[0-9]*\).*/\1/p')
^
SyntaxError: invalid syntax
Any idea on what I do wrong?
command in windows (cmd runned in admin mode): python speedtest.shCode: Select all
#!/bin/bash #setup port=8080 username=xxxx password=xxxx host=localhost pingidx=239 downloadidx=241 uploadidx=240 # 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"
-
- Posts: 110
- Joined: Sunday 22 March 2015 7:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Holland
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Nice one'sgjaa wrote:I've made some icons (I don't like the default Icon )
One for up and download (speed)
and one for ping (ping)
Tip
I did not see them when i try to change them for the Custum Sensor afther uploading the icons in Domoticz.
I reboot did not solve the problem.
You need the do a browser refresh and then you can see them.
Re: How to monitor your internet connection with virtual custom sensors
When i use the IP I get this error:mikeoo wrote:johan99 wrote:mikeoo wrote: Try to change host=localhost to host=ip-adres of domoticz and test if that change something.
File "speedtest2.sh", line 7
host=192.168.0.188
^
SyntaxError: invalid syntax
I says the zero in the adress is the problem, dont know why, the adress is correct. When I edit the file i use a Windows PC and notepad++ and choose unix EOL.
-
- Posts: 110
- Joined: Sunday 22 March 2015 7:35
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Holland
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
You can try the use a different editor. Lot of Windows editors give problems with linux files and to be sure try an other one. Because it say that er is a problem it looks like notepad++ does something with the file. Try Sublime Text https://sublimetext.com/3 that one is working fine with linux filesjohan99 wrote:When i use the IP I get this error:mikeoo wrote:johan99 wrote:
File "speedtest2.sh", line 7
host=192.168.0.188
^
SyntaxError: invalid syntax
I says the zero in the adress is the problem, dont know why, the adress is correct. When I edit the file i use a Windows PC and notepad++ and choose unix EOL.
Create a new file again, don't copy and past the old one because then you can copy the strange characters in to the new file.
If it still not working maybe a pyhton version problem, try to run it without python command and just speedtest
viewtopic.php?f=21&t=13814&p=100190&hil ... ws#p100190
Re: How to monitor your internet connection with virtual custom sensors
I tried sublimetext now aswell and get the same issues.
I think I set a Raspberry Pi up (have one not used for anything) and use that for this instead. Using it as a 2:nd Domoticz server. When reading this forum I realize that most of you use RP and most guides are written for RP.
Thanks for the help though. And I'll keep on using the Windows server as my main server for Domoticz and are intrested to hear from you who got everything working fine with Win and Domoticz.
I think I set a Raspberry Pi up (have one not used for anything) and use that for this instead. Using it as a 2:nd Domoticz server. When reading this forum I realize that most of you use RP and most guides are written for RP.
Thanks for the help though. And I'll keep on using the Windows server as my main server for Domoticz and are intrested to hear from you who got everything working fine with Win and Domoticz.
-
- Posts: 20
- Joined: Thursday 26 November 2015 8:31
- Target OS: NAS (Synology & others)
- Domoticz version:
- Contact:
Re: RE: Re: How to monitor your internet connection with virtual custom sensors
How this icons can be added ?gjaa wrote:I've made some icons (I don't like the default Icon )
One for up and download (speed)
and one for ping (ping)
- sincze
- Posts: 1300
- Joined: Monday 02 June 2014 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.4
- Location: Netherlands / Breda Area
- Contact:
Re: RE: Re: How to monitor your internet connection with virtual custom sensors
I found the solution in the wikidtech wrote:How this icons can be added ?gjaa wrote:I've made some icons (I don't like the default Icon )
One for up and download (speed)
and one for ping (ping)
http://www.domoticz.com/wiki/Custom_ico ... binterface
Pass2php
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
LAN: RFLink, P1, OTGW, MySensors
USB: RFXCom, ZWave, Sonoff 3
MQTT: ZIgbee2MQTT,
ZWAVE: Zwave-JS-UI
WIFI: Mi-light, Tasmota, Xiaomi Shelly
Solar: Omnik, PVOutput
Video: Kodi, Harmony HUB, Chromecast
Sensors: You name it I got 1.
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Hi all, first of all, great feature!! i carried out all the steps bit for some reason the custom sensors don't show the values. When I run the script I do get the correct info, but the sensors are not showing anything. Does anyone have an idea where I went wrong?
Sent from my iPhone using Tapatalk
Sent from my iPhone using Tapatalk
- EdwinK
- Posts: 1820
- Joined: Sunday 22 January 2017 21:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Rhoon
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
I like this script a lot. One small thing though.
After the data, I get a '0' instead of the right value (ms, Mbp/s). Can this be fixed?
Forget about the first tile, that is from another script.
After the data, I get a '0' instead of the right value (ms, Mbp/s). Can this be fixed?
Forget about the first tile, that is from another script.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
-
- Posts: 62
- Joined: Thursday 29 December 2016 18:17
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Finland
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
I think that you need to modify those, Device (Ping, Download and Upload) > Edit > Axis label (add ms or Mbp/s depending device)
- EdwinK
- Posts: 1820
- Joined: Sunday 22 January 2017 21:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Rhoon
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Ah.. Of course. Thanks
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Hey guys,
Really like the script! its working well when manually run. but for some reason I can't seem to get the output in domoticz.
does anyone have an idea?
I am running it on a Synology NAS.
Thnx in advance!
Really like the script! its working well when manually run. but for some reason I can't seem to get the output in domoticz.
does anyone have an idea?
I am running it on a Synology NAS.
Thnx in advance!
- EdwinK
- Posts: 1820
- Joined: Sunday 22 January 2017 21:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Rhoon
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Running this on a Synology NAS too, and had it working in matter of minutes.
Synology doesn't have apt-get, so you need to find another way to get the files. I used easy_install, but can't quite remember how I did install that.
Search for easy_install and Synology on the Google.
Synology doesn't have apt-get, so you need to find another way to get the files. I used easy_install, but can't quite remember how I did install that.
Search for easy_install and Synology on the Google.
Last edited by EdwinK on Tuesday 18 April 2017 20:00, edited 1 time in total.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
- EdwinK
- Posts: 1820
- Joined: Sunday 22 January 2017 21:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: BETA
- Location: Rhoon
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
gjaa wrote:I've made some icons (I don't like the default Icon )
One for up and download (speed)
and one for ping (ping)
Thanks for those icons
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
-
- Posts: 390
- Joined: Wednesday 30 November 2016 11:58
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.10717
- Contact:
Re: How to monitor your internet connection with virtual custom sensors
Hi Edko66,
is there a chance you can help me out here?
since I have no username and password for domoticz, this is my script.
I can see the output.txt file it not in the same directory where thie stdomo.sh and speedtest-cli are in. shoudl this be?
is there a chance you can help me out here?
since I have no username and password for domoticz, this is my script.
Code: Select all
#!/bin/bash
#setup
host=192.168.10.21
port=8084
pingidx=8
downloadidx=6
uploadidx=7
# no need to edit
/volume1/homes/admin/Speedtest/speedtest-cli --server 5302 > 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://$host:$port/json.htm?type=command¶m=udevice&idx=$pingidx&svalue=$ping"
curl -s -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command¶m=udevice&idx=$downloadidx&svalue=$download"
curl -s -i -H "Accept: application/json" "http://$host:$port/json.htm?type=command¶m=udevice&idx=$uploadidx&svalue=$upload"
Who is online
Users browsing this forum: Google [Bot] and 1 guest