Speedtest plugin wildly off?

I have symmetric 1Gbps fiber (FTTH) from AT&T. I consistantly get ~800Mbps both directions, with sub 10ms latency. However, since starting to use the speedtest component of HA, I find it’s results wildly off from what speedtest shows. See screenshot below. Speedtest.net on the left, and metrics from speedtest sensor. Both are using the same server (AT&T in san francisco) to make sure it was polling the same site

speedtest.net shows 2ms latency, 685 down (downloading a backup from B2 at the moment) and 876 Up, whereas current readings from HA sensor are 427Mbps down. 19Mbps up and 857ms latency.

What device is your ha running on? Can it handle a gigabit connection?

@silvrr
https://www.supermicro.com/products/system/2U/6027/SYS-6027TR-DTRF.cfm

2x E5-2630v2 (12C/24T total @2.6Ghz)
64GB RAM
10Gbit ISCSI mount for HA config folder.
Local storage is a 4x Intel DCS3610 400GB SSD’s in RAID5

Have you tried running Speedtest manually from the same machine to see what it can pull for speed?

seems it might be the python code. I tested both directly in the container and from the host system itself:

[email protected]:/tmp$ ./speedtest-cli --server 5026
Retrieving speedtest.net configuration...
Testing from AT&T U-verse (69.222.190.131)...
Retrieving speedtest.net server list...
Retrieving information for the selected server...
Hosted by AT&T (San Francisco, CA) [31.10 km]: 3.756 ms
Testing download speed................................................................................
Download: 852.75 Mbit/s
Testing upload speed................................................................................................
Upload: 392.62 Mbit/s
[email protected]:/tmp$ ./speedtest-cli --server 5026
Retrieving speedtest.net configuration...
Testing from AT&T U-verse (69.222.190.131)...
Retrieving speedtest.net server list...
Retrieving information for the selected server...
Hosted by AT&T (San Francisco, CA) [31.10 km]: 3.663 ms
Testing download speed................................................................................
Download: 858.11 Mbit/s
Testing upload speed................................................................................................
Upload: 128.95 Mbit/s
[email protected]:/tmp$ ./speedtest-cli --server 5026
Retrieving speedtest.net configuration...
Testing from AT&T U-verse (69.222.190.131)...
Retrieving speedtest.net server list...
Retrieving information for the selected server...
Hosted by AT&T (San Francisco, CA) [31.10 km]: 3.723 ms
Testing download speed................................................................................
Download: 883.45 Mbit/s
Testing upload speed................................................................................................
Upload: 380.27 Mbit/s

The latency looks better (not 800ms like the GUI, but that could be a temporary thing), but the upload performance is nowhere near what “speedtest.net” is. HA is reporting sometimes 200+ ms latency and as low as 20Mbps speeds. I wonder if it’s the speedtest code itself.

Have you resolved this issue ? I am experiencing the same here. Testing from another machine with command line shows the correct speed. I may gonna do just that and using MQTT to send the value over.

nope. It’s still showing like 700 Down 300 up, despite everything else saying 970/970

ok. I fixed my issue. The culprit was PiHole and / or AdGuard.
Stopping them did not help, I had to remove the add-ons from Hassio completely.
Everything is back to normal. I do plan to setup PiHole using a different VM.

At least for downloading, I was able to fix this script. The problem I saw was that near the end of the test, there were a lot of 0 bit entries in the array of received data. The way the script works it starts a timer when downloading starts and stops a timer when it’s all done. The problem with a bunch of 0 bit data was that it added time to the counter while not receiving more data (essentially it’s done, but the script doesn’t recognize it yet).

YMMV, but i made the following changes to keep track of time better and ignore the time of 0 bits received:

speedtest.py (approx line 1472)

    finished = []
    times = []  # added array

    def consumer(q, request_count):
        while len(finished) < request_count:
            bitstart = timeit.default_timer()  # added timer start
            thread = q.get(True)
            while thread.isAlive():
                thread.join(timeout=0.1)
            finished.append(sum(thread.result))
            times.append(timeit.default_timer() - bitstart) # store timer length
            callback(thread.i, request_count, end=True)

    q = Queue(self.config['threads']['download'])
    prod_thread = threading.Thread(target=producer,
                                   args=(q, requests, request_count))
    cons_thread = threading.Thread(target=consumer,
                                   args=(q, request_count))
    start = timeit.default_timer()
    prod_thread.start()
    cons_thread.start()
    while prod_thread.isAlive():
        prod_thread.join(timeout=0.1)
    while cons_thread.isAlive():
        cons_thread.join(timeout=0.1)

    stop = timeit.default_timer()
    self.results.bytes_received = sum(finished)
    mytime = 0 # added variable to store timer sum
    for x in range(0, len(finished)): # cycle through finished date
        if(finished[x] > 0): # Ignore 0 bit received
            mytime = mytime + times[x]  # sum timers
    self.results.download = (
        (self.results.bytes_received / (mytime)) * 8.0  # change to new timer value for calculation
    )

Didnt make much of a difference

before

[email protected]:/tmp$ ./speedtest-cli --server 5026
Retrieving speedtest.net configuration...
Testing from AT&T U-verse (69.222.xxx.yyy)...
Retrieving speedtest.net server list...
Retrieving information for the selected server...
Hosted by AT&T (San Francisco, CA) [30.72 km]: 29.646 ms
Testing download speed................................................................................
Download: 701.09 Mbit/s
Testing upload speed................................................................................................
Upload: 278.23 Mbit/s

after

[email protected]:/tmp$ ./speedtest-cli --server 5026
Retrieving speedtest.net configuration...
Testing from AT&T U-verse (69.222.xxx.yyy)...
Retrieving speedtest.net server list...
Retrieving information for the selected server...
Hosted by AT&T (San Francisco, CA) [30.72 km]: 18.535 ms
Testing download speed................................................................................
Download: 749.70 Mbit/s
Testing upload speed................................................................................................
Upload: 289.94 Mbit/s

but now im thinking it’s something with that server. When I ran it on its own, without a server:

[email protected]:/tmp$ ./speedtest-cli
Retrieving speedtest.net configuration...
Testing from AT&T U-verse (69.222.xxx.yyy)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by CodecCloud Limited (Fremont, CA) [16.76 km]: 19.215 ms
Testing download speed................................................................................
Download: 817.54 Mbit/s
Testing upload speed................................................................................................
Upload: 522.64 Mbit/s

This still pales in comparison though to the browser, which coincidentally goes to the same SF server I got the 200ish Mbps up:

Just registering that this is also an issue for me.

I have a FTTC 70/20 connection and via a browser my speed is showing as 72/18 but in the HA sensor it’s showing 14/12.

Ping is also ~50% too high compared to speedtest.net in a browser

I have set up speedtestdotnet to use the same server as my browser to make sure.

What hardware are you running HA on?

Two good sources of info on this:

I’m running it in docker on an AM1 5350 with an Intel i350-T2 card and via gigabit switch and Cat 6.

My windows pc (a new-ish Ryzen PC) via the same network consistently reports different speeds.

I’ve also just installed and run speedtest-cli on the server (outside of docker) and the reported speeds are the same as windows.

Debian Buster I should add is the host OS

So it’s the docker container limiting the bandwidth.

Unless I can find a way to run speedtest-cli within the container there’s no way knowing if it’s a docker issue, or an issue with the integration.

I’m not the first to report this though so I suspect it’s probably not Docker. And why would the Docker container limit the bandwidth anyway? I’ve not configured it to do that.

Hello everyone.
I have the same issue. The culprit is adguard.

Before the fall : pihole
After the fall : adguard