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.
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.
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.
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.
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.
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.
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.
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.
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:
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.