[Feature] Allow api access to trigger speed tests
Closed this issue · 3 comments
General
- My feature does not exist in the latest version of MySpeed.
- I have checked that my feature has not been suggested by anyone else.
Your Idea
My plan would be to disable scheduled speed tests as they can often conflict with high traffic times, and use external monitoring to trigger a test. E.g. I monitor the external interface flow at my firewall and once it drops beneath a set level for more than 'x' seconds trigger a speed test (limited to 1 per hour)
To allow for this I need to be able to disable all speed test schedules, and allow the tests to be triggered remotely. Also if possible I would like the results/stats to be also available via an api to allow for my home automation system to query and display results on screens around the house when needed.
Hi, thanks for your suggestion. MySpeed already has a simple REST-API you can hook into. You can find a complete collection of API endpoints here on Postman.
In order to do what you described, you need to do the following:
- Disable speedtests. You can do this by setting the crontab (
Settings
>Set frequency
>Set manually
) to a time that never executes or takes a really long time (e.g.0 0 1 1 *
- once a year) - Trigger a
POST
request to/api/speedtests/run
. This is also documented here
I'm not sure what home automation system you are using but if it can integrate with Prometheus, you can use the Prometheus endpoint (see #687).
If not, you can get the speedtest data as JSON. You can either get it raw in a list, by averages or get the statistics. This returns the same data as seen in the UI.
Hope that helps! :)
That really does help, I'm just sorry I didn't find this myself. I'm away at the moment but will try this as soon as I return.
I use 'home assistant' so shouldn't have tookmany issues capturing what I need via either method.
Thanks again for the info and pointers.
Using home assistant I set up the following in yaml and call the service in an automation.
rest_command: run_speed_test: method: post url: "http://host:port/api/speedtests/run"
I am working on pulling results into a dashboard, but that is a lower priority for me.
Many thanks for your help.