Speedtest Alexa-Skill and Cronjob
An easy to use script test the speed (down-, upload and ping) of your ISP regularly (cronjob) and return the results with an Alexa Skill.
##Table of contents
- Start the Speedtest
- Installation Speedtest Alexa Skill
- Setup Twitter
config.json and setup the values.
- Install pip packages
pip install -r requirements.txt
- Install python-tk
sudo apt install python-tk
Start the Speedtest
python speedtest.py to measure the speed.
It will automatically create a sqlite database if not already existing.
Plot a diagram
plot.py to plot the last 60 days.
import.py filename.csv to import your existing data into your database.
The CSV format to import is as follows:
date,time,timezone,ping,download (MBit/s),upload (MBit/s) 2017-02-19,18:45,CET,47.126,4.07,1.90 2017-02-19,19:00,CET,66.101,3.94,0.86
You might adapt the script to import your own files.
To measure your speed all 15 minutes, add the following line to your crontab.
*/15 * * * * python /path/to/speedtest.py /path/to/config.json
Installation Speedtest Alexa Skill
Installation of Flask-Ask and Ngrok
First you need to install Flask-Ask with:
pip install flask-ask
In the next step you need to go to https://ngrok.com/download and download the latest Linux ARM build with:
Now you can run your ngrok Server with:
./ngrok http 5000
Your Localhost-Server with a ngrok-Subdomain is now running. The output of this command looks similar to this. To use this Alexa-Skill you need to copy the HTTPS-Address into the Amazon Developer Console later.
Setup Alexa Skill
Follow the instructions here (starting from Configure the Skill) and copy the necessary code snippets from
speech_assets folder into the necessary places.
If you want to create more Utterances you'll find a useful tool to expand utterances here. An example of how you would write them is shown below.
MeasureSpeedIntent messe die (upload / internet / download) (/geschwindigkeit) MeasureSpeedIntent nimm eine messung (/vor) MeasureSpeedIntent starte eine (/neue/weitere) Messung
Start Alexa Skill
All you need to do now is to make sure you have at least one record in the
speedtest.db and then run
Once you have setup your Twitter App you should udpate the
twitter_* values in the config.json. Then it should tweet automatically. Do not forget to set the
twitter_enabled value in your config to true.
How to setup the path to the
*.db on a Raspberry Pi?
Keep in mind that the cronjob has a different working directory and therefore its best to use absolute paths in your
config.json file for the database.