Can I access the Unifi Dream Machine's own speed test results in Home Assistant?

This information is definitely available from the gateway.
image

I’d prefer to use this instead of installing the speedtest integration for a few different reasons.

(1) I’ll get more accurate results on the Unifi DM SE where “accurate” means the closest measurement of the true bandwidth my ISP is actually supplying

(2) I’ll avoid extra load on my HA VM. My HA is running on pretty beefy hardware but it’s unnecessary to tax it more. I also route all my IoT traffic behind a VPN (and HA OS is on that as well) so accuracy won’t be as good.

(3) Finally, the native HA speedtest integration isn’t super accurate. For best results I’ll need to also install the speedtest addon from a custom repository and it’s just more complexity (even if trivial) and load when I can just get the result from the Unifi gatefway ideally.

Thanks.

2 Likes

Would like to see that as well but I’m not sure if that info is exposed to the Unifi API’s.

If you at least want something, and you don’t like the inaccuracies of the HA speedtest integration, may I offer you this in-between:

# SpeedTest sensor
command_line:
  sensor:
    name: SpeedTest
    icon: mdi:speedometer
    command: /config/deps/ookla/speedtest --accept-license --accept-gdpr -p no -f json
    command_timeout: 30
    scan_interval: 3600
    json_attributes:
      - timestamp
      - ping
      - download
      - upload
      - packetLoss
      - server
    value_template: "{{ value_json.timestamp }}"
    device_class: timestamp

Put that in your configuration.yaml along with the speedtest binary in the path specified, then set up some helpers for upload/download:

{{ (states.sensor.speedtest.attributes.download.bandwidth | float / 125000) | round(0) }}

Set the units to Mbit/s, etc.

The only real downside is this is coming from the HA system, so if you’ve got only 1gb network, that’s your peak, compared to your DM or XG or whatever where you might have a much faster up/down directly from your ISP.

I’m keen to figure this out too. Here’s a link to a rabbit hole: Retrieve Speed Test Results · Issue #42 · Art-of-WiFi/UniFi-API-client · GitHub

I assume if we follow that rabbit hole, we’ll eventually get to wonderland. I mean the speed test result. But that’s a fun thing for another day.

It looks like it just needs some work in HA; the speedtest_status() function is in the Python aiounifi module already (Kane610/aiounifi: Asynchronous library to communicate with Unifi Controller).

2 Likes

Stumbled across this thread while looking to do the same.

This looks like it might work:
https://github.com/biofects/HA-Unifi-Speedtest

edit:
Set up with a read only local account, works a treat.

3 Likes

How?! I only get “Cannot connect to the UniFi Controller.”

Same here; I think it might work for a UDM only. I looked at the code and tried specifying the host various ways, none of them worked.

2 Likes

Updates have been made to support unifi controller software, thanks fornthe help, i know there are still a few issues that are being addressed.

2 Likes

Hello biofects this integration looks awesome exactly what im looking for! However I use an EFG at home and I cant seem to get it to work :frowning: Is there a way you could add EFG support? It says the API is up so its connecting but running the service to get a speedtest never populates a result so maybe its different object than a UDM… Let me know if you need me to run some commands on my EFG if you need me to?

Cheers,

Christian.

I am working on a new update fornthe speedtest. I will investigate if the EFG has same api. If not i might need to check on my other plugin GitHub - biofects/HA-UniFi-Site-Manager: Home Assistant plugin to gather details on multiple Ubiquiti Sites

I’ve recently done this custom component that allows speed test from the udmpro(should work on other unifi gateways). And getting other WAN info

2 Likes

I tried the other plug in and it doesnt work either. It adds my site and says connected and it can find all my aps, switches and the efg but nothing else is populated. :frowning:

I am after exactly that your speedtest one provides so let me know if you need me to run anything on my efg!

Hello ! I tried your custom config and it worked! However I have wan1 and wan2 and its only showing me wan2 any ideas why?

I can’t test as only have 1 WAN but have added sensors in v0.5.1 that hopefully capture both WAN1 and WAN2

hi ok i tried 0.5.1 its pretty cool some parts of my primary wan are working now it can see current throughput and sees my primary wan ipv4 address. But the speedtest results its showing are from WAN2 not my primary WAN any ideas on that?

OK its working now! I kicked off manual speed test on wan1 and now its showing. I wonder if its just showing which test ran last because wan2 test was newer…

Not sure, glad its working

thanks its very cool do you think you will expand it to other things? like throughput of say AP uplink ports ect? or just keep it WAN focused?

Just keep it WAN focused I think. I could do a new devices integration that does throughputs for switches and access points etc but it’ll be a while before I can get to it

1 Like

This is the best integration! Exactly what I wanted.