Speedtest.net integration alternative

Official Speedtest.net integration has been broken, from time to time, either from speedtest-cli or Home Assistant changes. There is an alternative in running a separate Docker of Speedtest Tracker (not affiliated) as it includes an API (available at /api/speedtest/latest) and importing the results in Home Assistant are fairly easy:

Example of API results: {“message”:“ok”,“data”:{“id”:123456789,“ping”:9.467,“download”:1880.9072,“upload”:817.7248,“server_id”:123456789,“server_host”:“speedtest.xxx.xx:8080”,“server_name”:“XXXXXXXXXXX”,“url”:“https://www.speedtest.net/result/c/123456789-123456789-123456789-123456789-123456789”,“scheduled”:true,“failed”:false,“created_at”:“2024-01-23T08:00:20.000000Z”,“updated_at”:“2024-01-23T08:00:20.000000Z”}}

As the Speedtest requires a fair amount of computing power, running it on a separate machine can be useful in cases where the Home Assistant instance runs on a low performance hardware (Raspberry Pi, low power NUCs, etc.) or when a multi-gigabit network card is a available to a server grade machine but not to Home Assistant.

- platform: rest
  resource: http://192.168.0.46:45043/api/speedtest/latest
  name: Download Speed
  value_template: "{{ value_json['data']['download'] }}"
  unit_of_measurement: Mbps
  unique_id: '0100000000001'
- platform: rest
  resource: http://192.168.0.46:45043/api/speedtest/latest
  name: Upload Speed
  value_template: "{{ value_json['data']['upload'] }}"
  unit_of_measurement: Mbps
  unique_id: '0100000000002'
- platform: rest
  resource: http://192.168.0.46:45043/api/speedtest/latest
  name: Ping
  value_template: "{{ value_json['data']['ping'] }}"
  unit_of_measurement: ms
  unique_id: '0100000000003'

If planning to share the results, or view them at a later time, an URL sensor can be imported.

- platform: rest
  resource: http://192.168.0.46:45043/api/speedtest/latest
  name: URL
  value_template: "{{ value_json['data']['url'] }}"
  unique_id: '0100000000004'

Also, remainder of API values (server_id, server_host, server_name, scheduled, failed, created_at, updated_at) can be useful for serving additional sensors.

Home Assistant card:

image

Speedtest Tracker card:

2 Likes

Hello i added the sensor configuration into my home assistant configuration yaml but after restart i cannot found the sensors… what is wrong ?
may uou share the card code too ?
Thanks

Logs? Where are they?

Below is the code for the card.

To be sure I understood your problem: you are not using the official speedtest integration in Home Assistant; instead, you are using the Speedtest Tracker on a separate machine with REST manual sensors, right?

Card
cards:
  - cards:
      - cards:
          - align: split
            card_style:
              border-radius: 5px
            columns: 1
            entities:
              - entity: sensor.ping
            entity_row: true
            max: 100
            padding: 4px
            show_icon: true
            title_position: inside
            type: custom:bar-card
        type: horizontal-stack
    type: horizontal-stack
  - cards:
      - color_thresholds:
          - color: red
            value: 0
          - color: yellow
            value: 1500
          - color: green
            value: 1800
        entities:
          - sensor.download_speed
        font_size: 70
        height: 70
        hours_to_show: 24
        icon: mdi:download
        line_width: 2
        name: Download
        points_per_hour: 1
        show:
          extrema: true
          fill: true
        type: custom:mini-graph-card
      - color_thresholds:
          - color: red
            value: 0
          - color: yellow
            value: 600
          - color: green
            value: 800
        entities:
          - sensor.upload_speed
        font_size: 70
        height: 70
        hours_to_show: 24
        icon: mdi:upload
        line_width: 2
        name: Upload
        points_per_hour: 1
        show:
          extrema: true
          fill: true
        type: custom:mini-graph-card
    type: horizontal-stack
type: vertical-stack
view_layout:
  width: 10
  max_cols: 10

Thank you so much… all ok now