#!/usr/bin/env bash | |
########################################################################### | |
# Originally written by: Henrik Bengtsson, 2014 | |
# https://github.com/HenrikBengtsson/speedtest-cli-extras | |
# Modified to use IFTTT by: Alasdair Allan, 2015 | |
# License: GPL (>= 2.1) [http://www.gnu.org/licenses/gpl.html] | |
########################################################################### | |
# Character for separating values | |
# (commas are not safe, because some servers return speeds with commas) | |
sep=";" | |
# Temporary file holding speedtest-cli output | |
user=$USER | |
if test -z $user; then | |
user=$USERNAME | |
fi | |
log=/tmp/$user/speedtest-csv.log | |
# Local functions | |
function str_extract() { | |
pattern=$1 | |
# Extract | |
res=`grep "$pattern" $log | sed "s/$pattern//g"` | |
# Drop trailing ... | |
res=`echo $res | sed 's/[.][.][.]//g'` | |
# Trim | |
res=`echo $res | sed 's/^ *//g' | sed 's/ *$//g'` | |
echo $res | |
} | |
# Display header? | |
if test "$1" = "--header"; then | |
start="start" | |
stop="stop" | |
from="from" | |
from_ip="from_ip" | |
server="server" | |
server_dist="server_dist" | |
server_ping="server_ping" | |
download="download" | |
upload="upload" | |
share_url="share_url" | |
else | |
mkdir -p `dirname $log` | |
start=`date +"%Y-%m-%d %H:%M:%S"` | |
if test -n "$SPEEDTEST_CSV_SKIP" && test -f "$log"; then | |
# Reuse existing results (useful for debugging) | |
1>&2 echo "** Reusing existing results: $log" | |
else | |
# Query Speedtest | |
/usr/local/bin/speedtest-cli --share > $log | |
fi | |
stop=`date +"%Y-%m-%d %H:%M:%S"` | |
# Parse | |
from=`str_extract "Testing from "` | |
from_ip=`echo $from | sed 's/.*(//g' | sed 's/).*//g'` | |
from=`echo $from | sed 's/ (.*//g'` | |
server=`str_extract "Hosted by "` | |
server_ping=`echo $server | sed 's/.*: //g'` | |
server=`echo $server | sed 's/: .*//g'` | |
server_dist=`echo $server | sed 's/.*\\[//g' | sed 's/\\].*//g'` | |
server=`echo $server | sed 's/ \\[.*//g'` | |
download=`str_extract "Download: "` | |
upload=`str_extract "Upload: "` | |
share_url=`str_extract "Share results: "` | |
fi | |
# Standardize units? | |
if test "$1" = "--standardize"; then | |
download=`echo $download | sed 's/Mbits/Mbit/'` | |
upload=`echo $upload | sed 's/Mbits/Mbit/'` | |
fi | |
# Send to IFTTT | |
secret_key="SECRET_KEY" | |
value1=`echo $server_ping | cut -d" " -f1` | |
value2=`echo $download | cut -d" " -f1` | |
value3=`echo $upload | cut -d" " -f1` | |
json="{\"value1\":\"${value1}\",\"value2\":\"${value2}\",\"value3\":\"${value3}\"}" | |
curl -X POST -H "Content-Type: application/json" -d "${json}" https://maker.ifttt.com/trigger/speedtest/with/key/${secret_key} |
This comment has been minimized.
This comment has been minimized.
:( hmm, still Syntax error: "(" unexpected |
This comment has been minimized.
This comment has been minimized.
speedtest-ifttt.sh: 21: speedtest-ifttt.sh: Syntax error: "(" unexpected |
This comment has been minimized.
This comment has been minimized.
If you see "speedtest-ifttt.sh: 21: speedtest-ifttt.sh: Syntax error: "(" unexpected" you have to remove the "function" in line 21. |
This comment has been minimized.
This comment has been minimized.
or run it with ... /bin/bash /speedtest-ifttt.sh |
This comment has been minimized.
This comment has been minimized.
sudo ./speedtest-ifttt.sh |
This comment has been minimized.
This comment has been minimized.
Hi, Thanks so much for your efforts in producing this. I got this working in an evening, which given my skill level, I'm delighted with. If I get chance, I'll write something on the IFTTT setup too, unless you have already blogged that somewhere? Thanks once again, Ian |
This comment has been minimized.
This comment has been minimized.
Hello, |
This comment has been minimized.
This comment has been minimized.
@Stybyk @vacano tested, it works for me. Current IFFFT web interface is a bit confusing, maybe you have a mistake in your configuration. Make sure you have "Log Speedtest results to Spreadsheet" applet in https://ifttt.com/my_applets
Then open Maker service setting page: https://ifttt.com/services/maker/settings
Select and open your URL in your browser to test your applet manually. Finally, copy/paste YOUR_KEY into the speedtest-ifttt.sh script (line 82) and run your script. It should work OOB. |
This comment has been minimized.
This comment has been minimized.
I keep running into an issue with my key do I enter it in both fields listed secret key? Send to IFTTTsecret_key="SECRET_KEY" |
This comment has been minimized.
This comment has been minimized.
I answered my own question updated both fields with my key however my main issue was I never name my applet on Maker Web Hooks.. |
This comment has been minimized.
This comment has been minimized.
Fantastic mod of speedtest-extras - question regarding output to Google Sheet: |
This comment has been minimized.
This comment has been minimized.
sudo ./speedtest-ifttt.sh |
This comment has been minimized.
This comment has been minimized.
Hi |
This comment has been minimized.
This comment has been minimized.
@garycrj perhaps you dont have speedtest-cli installed? sudo pip install speedtest-cli |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I am trying to figure out how to find out what the "SECRET_KEY" value needs to be |
This comment has been minimized.
This comment has been minimized.
@hornjt75862, Secret_Key -> Edit line #82(above -in the code)secret_key="SECRET_KEY" Hope this helps |
This comment has been minimized.
This comment has been minimized.
Your secret key is generated when you connect the IFTTT maker channel, and is shown here, https://ifttt.com/maker |
This comment has been minimized.
This comment has been minimized.
I’ve got everything running (apparently) I get the message ‘Congratulations! You’ve fired the speedtest event’ but I don’t get a spreadsheet created in my google sheets. Any pointers on what I have to do to get this link working? |
This comment has been minimized.
This comment has been minimized.
Hi - i was wondering if there was a way to get this to pass a 4th value to the IFTTT channel. I added the relevant values here (value4) value1= But when i go to the IFTTT applet and att |||{{value4}} to the applet it says there is an error and wont let me save :( |
This comment has been minimized.
This comment has been minimized.
i keep getting the following error : speedtest-ifttt.sh: line 87: curl: command not found |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Not sure about #1 as for me that ingredient comes w/ local time (though I do have that annoying string format), but your #2 custom field can be done w/ something like =(INDIRECT(CONCAT("E", ROW()))-INDIRECT(CONCAT("E", ROW()-1)))/INDIRECT(CONCAT("E", ROW()-1)) Just change the colname to your download speed col. |
This comment has been minimized.
This comment has been minimized.
Is there any update to the script or where it pulls the speeds from? At my old apartment I was paying for 60Mb/s down and my sheets were correctly averaging around 60. Now that I'm at a new location and new house, I'm paying for 100Mb/s down and it's averaging at 70. When I use speedtest.net, it shows 70Mb/s. When I use speedof.me it shows 100Mb/s+. Bandwidthplace.com shows around 70. And testmy.net shows 100Mb/s+. So, which is it!? |
This comment has been minimized.
This comment has been minimized.
Is there a way to record the mac address of the triggering machine? |
This comment has been minimized.
This comment has been minimized.
@mrminus Did you ever figure that out? Could you share? |
This comment has been minimized.
This comment has been minimized.
is this still working? i cannot for the life of me get this to create a spreadsheet on google. |
This comment has been minimized.
This comment has been minimized.
me too ! |
This comment has been minimized.
This comment has been minimized.
Doesn't work anymore, probably cause of changes with API Google: |
This comment has been minimized.
This comment has been minimized.
The script does work if you follow the instructions here: http://grantglazer.com/automatically-log-your-internet-speeds-with-a-raspberry-pi/ If you still experience the Google Sheets error, the disconnect the Google Drive service in IFTTT, and reconnect it. That should fix your issue. |
This comment has been minimized.
This comment has been minimized.
The script doesn't work. I think it's something to do with IFTT and Google and the triggers. |
This comment has been minimized.
This comment has been minimized.
i got it working previously, but now, im trying to look for the secretkey in ifttt.com. its just not there anymore. |
This comment has been minimized.
This comment has been minimized.
I know it's an old post, but, did you ever figure it out? It's suppose to parse the new value but doesn't work... |
This comment has been minimized.
This comment has been minimized.
IFTTT doesn't support additional values unfortunately.
Sorry,
Al.
… On 4 Mar 2020, at 18:36, jackdanpr ***@***.***> wrote:
Hi - i was wondering if there was a way to get this to pass a 4th value to the IFTTT channel.
I added the relevant values here (value4)
value1=echo $server_ping | cut -d" " -f1
value2=echo $download | cut -d" " -f1
value3=echo $upload | cut -d" " -f1
value4=echo $server | cut -d" " -f1
json="{"value1":"${value1}","value2":"${value2}","value3":"${value3}","value4":"${value4}"}"
curl -X POST -H "Content-Type: application/json" -d "${json}" https://maker.ifttt.com/trigger/speedtest/with/key/${secret_key} <https://maker.ifttt.com/trigger/speedtest/with/key/$%7Bsecret_key%7D>
But when i go to the IFTTT applet and att |||{{value4}} to the applet it says there is an error and wont let me save :(
I know it's an old post, but, did you ever figure it out? It's suppose to parse the new value but doesn't work...
Thanks,
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <https://gist.github.com/bafc70a347f3b9526d30?email_source=notifications&email_token=AAANC6KW5DUTHW3KD4QHD2LRF2NRJA5CNFSM4IMFEYQ2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAGDKPK#gistcomment-3200245>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAANC6ITBJ3YH32YARLT4M3RF2NRJANCNFSM4IMFEYQQ>.
|
This comment has been minimized.
This comment has been minimized.
I am getting leading decimals in my output. |
This comment has been minimized.
This comment has been minimized.
I was able to resolve this using sed to replace leading decimal points with nothing. |
This comment has been minimized.
This comment has been minimized.
I am not getting anything in google drive. When clicking the check now in the IFTTT recipe I get a 'There was an error during check process' message. Any ideas?? |
This comment has been minimized.
This comment has been minimized.
Did you set the trigger in ifttt to "speedtest" |
This comment has been minimized.
This comment has been minimized.
@kkasberg sorry I am new to IFTTT but if you mean the title of the applet then yes. |
This comment has been minimized.
This comment has been minimized.
I mean where it says "Event Name" (blank above) use "Speedtest". |
This comment has been minimized.
This comment has been minimized.
https://maker.ifttt.com/trigger/speedteest/with/key/ gives me: But still nothing in google drive |
This comment has been minimized.
This comment has been minimized.
It will give that result because the event fired is "speedtest". I in ifttt you don't enter that as the event name it won't post to google sheets. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Ok I have added that and getting somewhere now however nothing appears in Google Sheets unless I hit the Check Now button in IFTTT. Doing this seems to then send all the 'queued' entries. |
This comment has been minimized.
This comment has been minimized.
It actually seems to do nothing for a while then several readings all come through together. I have it set to every 15mins in the cronjob but it takes a few hours to get written to google sheets. |
This comment has been minimized.
This comment has been minimized.
This happened to me also, and I resolved it by deleting my webhook secret key and having a new one created (then adding the new one back into the scripts). |
This comment has been minimized.
This comment has been minimized.
Thanks @kkasberg I will try that. |
This comment has been minimized.
This comment has been minimized.
Working! |
This comment has been minimized.
This comment has been minimized.
Everything was working great. On the sudden the script started filling it into a new spreadsheet speedtest(1) .... not sure where the copy came from and why its just posting it in there. |
This comment has been minimized.
This comment has been minimized.
Google Sheets have a maximum number of rows. Once you exceed that number it will auto-magically generate a new sheet. |
This comment has been minimized.
This comment has been minimized.
This has been working great since I started using it over a year ago, but it looks like something has changed on the IFTTT platform. The recipe, and my applet, both 404 now. It looks like it stopped working on March 8, 2021 around 2 PM CST. I'm wondering if anyone has found a workaround? |
This comment has been minimized.
I'm not super familiar with Bash.... but when I try to run this script - I'm getting:./speedtest-ifttt.sh: 21: ./speedtest-ifttt.sh: Syntax error: "(" unexpectedIt shouldn't have any impact but I have substituted my secret key.I figured out why it wasn't working... though the sheet is not being created in my gDrive... working on that issue nowFound the sheet, sync issue with my local machine😒