Speedtest.net integration alternative

You can also send the results directly from speedtest-tracker to HA using a webhook (no polling!)

Here’s an example template configuration that will parse the webhook payload directly into sensors:

template:
  - trigger:
      - platform: webhook
        webhook_id: <unique-webhook>
    sensor:
      - name: "Speedtest Download"
        state: "{{ trigger.json.download / 1024 / 1024 | round(2) }}"
        state_class: measurement
        unit_of_measurement: "Mbps"
      - name: "Speedtest Upload"
        state: "{{ trigger.json.upload / 1024 / 1024 | round(2) }}"
        state_class: measurement
        unit_of_measurement: "Mbps"
      - name: "Speedtest Ping"
        state: "{{ trigger.json.ping | round(2) }}"
        state_class: measurement
        unit_of_measurement: "ms"
      - name: "Speedtest Packet Loss"
        state: "{{ trigger.json.packetLoss }}"
        state_class: measurement
        unit_of_measurement: "%"
      - name: "Speedtest ISP"
        state: "{{ trigger.json.isp }}"
      - name: "Speedtest Result URL"
        state: "{{ trigger.json.speedtest_url }}"

On the speedtest-tracker side configure a webhook to call HA:

https://<homeassistant>:<port>/api/webhook/<unique-webhook>

Hello,
I have also set up this integration, all is working fine, but i have a lot of warnings in the logs:

> ValueError: Sensor sensor.upload_speed has device class 'None', state class 'None' unit 'Mbps' and suggested precision 'None' thus indicating it has a numeric value; however, it has the non-numeric value: 'None' (<class 'str'>)
> 2025-01-16 09:59:53.832 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.download_speed fails

Yaml code:

- platform: rest
  resource: http://127.0.0.1:7080/api/speedtest/latest
  name: Upload Speed
  value_template: "{{ value_json['data']['upload'] }}"
  unit_of_measurement: Mbps
  unique_id: '0100000000002'

Any pointers?

@robex2005 I just posted a webhook integration you can try. It’s the full config and doesn’t throw any errors in my HA. It also doesn’t require any polling from HA, all the data is pushed from speedtest based on events.

Working fine means you managed to integrate the sensors and only sometimes there are the errors in the logs? Or that only speedtest is working fine, but the integration in HA is not?
Can you post details of your setup? Speedtest and HA are installed on the same machine? I see you posted localhost for the sensor, however if speedtest is running in docker you would not be abble to access it from HA’s side and you need the actual IP of the instance running it.

Working fine means that i have data on the sensors, but the logs are full with the error specified (about 6MB of log in 48 hr …)
Yesterday i set up the webhook method posted by jackdaws, no more errors, and the sensors are ok also (gathering info from speedtest-tacker - set up in docker)