Making Speedtest work

Context:

  • I’m an idiot
  • I bought an intel N100, installed Proxmox and set up a VM with HAOS: this is working
  • I installed the official Speedtest integration, it shows “Unavailable”

I tried setting up an automation:

  • id: ‘1719434900032’
    alias: Speedtest download 20 min
    description: ‘’
    trigger:
    • platform: time_pattern
      hours: ‘*’
      minutes: /20
      condition: [ ]
      action:
    • service: homeassistant.update_entity
      target:
      entity_id: sensor.speedtest_download
      data: {}
      mode: single

If I force the automation to run (or go to the automation GUI and run the “Then do”), I get a “Action run successfully” message but the entity doesn’t update (I mean it shows “Last updated 9 minutes ago”, not “10 seconds ago”).

What I don’t know:

  • Is the Speedtest integration completely broken?
  • Is my HA install broken?
  • Is my Proxmox not set up properly (I don’t know if nor how I should open the port 8080 or whatever)?

I see many people have problems with the Speedtest integration but most say it’s unreliable, like doesn’t give reliable results. But I have no results at all.

I also saw some people install the Speedtest-cli and a Python wrapper and whatnot but before I spend two days setting up Samba and understanding the basic meaning of all that, I figured I should make a post, hopefully get some relevant guidance.

I’ve had similar issues.

When i first installed the addon, I turned off auto updating, which iirc, makes the speedtest addon run every hour.

So… I ended up following their other recommendations and setup an automation for the addon instead, and set this to be every 12 hours.

These are my conclusions:-

  1. As per the OP, despite the automation firing to update the entity, it never shows as updated.
  2. The entity does update if you leave the auto update turned on in the addon, but will occasionally fail.
  1. The entity does update if you leave the auto update turned on in the addon, but will occasionally fail.

My scenario is worse because I tried with it on and off (because I wasn’t sure of how the setting works: can I turn it off if I use an automation?) and the behavior was the same in both cases, it is ALWAYS unavailable.

image

Is there anything in the logs ? I think there is clearly a bug if its run via an automation (which they should fix), but the ‘normal’ auto update should work, and 99% of the time, does for me.

Try manually triggering your automation and go hunting in the log for anything that might tell you wants happening.

Is there anything in the logs ?

YES!

Logger: homeassistant
Source: helpers/update_coordinator.py:284
First occurred: 6:07:01 PM (2 occurrences)
Last logged: 6:07:07 PM

Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
File “/usr/local/lib/python3.12/site-packages/speedtest.py”, line 1493, in get_best_server
fastest = sorted(results.keys())[0]
~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/speedtestdotnet/coordinator.py”, line 76, in _async_update_data
return await self.hass.async_add_executor_job(self.update_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/concurrent/futures/thread.py”, line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/speedtestdotnet/coordinator.py”, line 64, in update_data
best_server = self.api.get_best_server()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/site-packages/speedtest.py”, line 1495, in get_best_server
raise SpeedtestBestServerFailure('Unable to connect to servers to ’
speedtest.SpeedtestBestServerFailure: Unable to connect to servers to test latency.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py”, line 312, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/components/speedtestdotnet/coordinator.py”, line 80, in _async_update_data
raise UpdateFailed(err) from err
homeassistant.helpers.update_coordinator.UpdateFailed: Unable to connect to servers to test latency.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/speedtestdotnet/init.py”, line 38, in _async_finish_startup
await coordinator.async_config_entry_first_refresh()
File “/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py”, line 284, in async_config_entry_first_refresh
raise ex
homeassistant.exceptions.ConfigEntryNotReady: Unable to connect to servers to test latency.

I don’t know what to do with that, though

Kind of guessing but it looks like the attempt to “auto-detect” a nearby SpeedTest Server did not work, so no server to connect to. Looks like in the SpeedTest integration you can CONFIGURE the server id directly so try that.
Maybe this link will be useful to see if you can find a server near you and its id.

Kind of guessing but it looks like the attempt to “auto-detect” a nearby SpeedTest Server did not work

Yes but why? Is the integration broken? Is it a Speedtest problem? Is it my Proxmox firewall that doesn’t have the right ports open and whatever?

I installed the Fast.com integration and it worked immediately, so it might not be my system that is is problematic (although you never know, it might be using another port or protocol or whatever). I’m still looking for a solution for Speedtest.net, though, as the Fast integration does only download.

Looks like in the SpeedTest integration you can CONFIGURE the server id directly so try that.

I tried setting it up with:

#Speedtestdotnet
speedtestdotnet:
server_id: 38994

in my configuration.yaml because it used to work like that (from old YouTube videos I watched) but it doesn’t support it anymore:

image

My bad. I thought you could enter a server-id there, but it is actually a pull down list of nearby servers that the integration has found. It looks like your list is empty as it doesn’t have a pull down arrow to click on, so not sure why the integration is not finding a list of nearby servers.

I did glance through the code and it looks like the get_server method has a list of URLs it uses.

        urls = [
            '://www.speedtest.net/speedtest-servers-static.php',
            'http://c.speedtest.net/speedtest-servers-static.php',
            '://www.speedtest.net/speedtest-servers.php',
            'http://c.speedtest.net/speedtest-servers.php',
        ]

Not sure what to tell you about this.

I will add however that if your internet speed is reasonably high (few hundred Mbps), then the SpeedTest integration will likely not produce the correct results anyway.
Here is another thread where others like myself use a binary from ookla to run these speedtests. Some have created their own sensors for the measured speeds/delays when using this binary.

1 Like

Visiting the websites on my laptop, I get:

429 Error - Too Many Requests

Your IP address is making too many requests. We ask that you limit requests to no more than 1 per second.

We make an attempt to be flexible, allowing small bursts in traffic. You have exceeded this threshold however and have been blocked.

Please reduce the speed at which your requests are made and try again after a while. If you feel you have reached this message in error, please contact us at noc @ speedtest.net and reference this error code.

Thank you

Which is surprising because I sure as hell don’t poll it every second (nor does the HA integration) and the actual https://www.speedtest.net/ is not blacklisted, I can run a test no problem.

That’s exactly what I was taking about in the last paragraph of my OP.

I didn’t understand all the subtleties of the various solutions presented, though.

I eventually got tired relying on the official Speedtest integration for various reasons and use SpeedTest Home Assistant Addon for getting speedtest readings. Works quite well and once set just forget.

Note that you still need the official Speedtest integration for this to work although you have to disable the automatic execution of the integration.

1 Like

Ohhh, I like that!

EDIT: Installed, I got it working

1 Like

I actually changed to that as well, as I didnt need the 1 hour updates from the addon, and it seems to work fine.

You switched to the add-on because you didn’t need the 1 hour updates from the official integration, correct?

If so, you can use an automation to start (and update the entities) the add-on as often as you’d like.

Yup… set it to 6 hours.

For the sake of completeness for people coming here, installing MrSuicideParrot’s hassio-speedtest-addon but are confused how to automatically update the speedtest entities through the add-on at regular intervals:

Create an automation like:

  alias: 'Run Speedtest addon every 6 hours'
  trigger:
    - platform: time_pattern
      hours: "/6"
  condition: []
  action:
    - service: hassio.addon_start
      data:
        addon: 6b87c29e_speedtest_addon
  mode: single

The above will trigger a speedtest every 6 hours and updates the entities accordingly.

Adjust time_pattern to your liking. Note that your IP-address might get blocked if you start to hammer the server used for internet speed testing (“429 Error - Too Many Requests”).

Perhaps another note for people coming here… from what I have seen, when HA-core is restarted, the Speedtest Integration is also restarted and it always runs its own speed test when it is restarted, so you may see results that don’t look quite right shortly after a HA-core restart.