Speedtest Integration No longer loading

Hi David, while my speedtest integration had a little hiccup (meanwhile solved by reinstalling twice), I was looking for a solution. I came across your message and found the screenshot with the very nice display of the speedtest data.
Can you give me a hint how you did that? It doesn’t seem to work with the on-board tools?
Best regards, Dirk

this is the lovelace code:

      - type: vertical-stack
        cards:
          - type: entities
            title: Internet
            show_header_toggle: false
            entities:
              - entity: sensor.speedtest_download
                secondary_info: last-updated
              - entity: sensor.speedtest_download_average
                secondary_info: last-updated
              - entity: sensor.speedtest_upload
                secondary_info: last-updated
              - entity: sensor.speedtest_upload_average
                secondary_info: last-updated
              - entity: sensor.speedtest_ping
                secondary_info: last-updated
              - entity: sensor.speedtest_lastrun
                format: relative
              - binary_sensor.fritz_box_7590_connection
          - type: horizontal-stack
            cards:
              - type: gauge
                name: Mbit/s Download
                unit: ' '
                min: 0
                max: 50
                severity:
                  red: 0
                  yellow: 30
                  green: 40
                entity: sensor.speedtest_download
              - type: gauge
                name: Mbit/s Upload
                unit: ' '
                min: 0
                max: 20
                severity:
                  red: 0
                  yellow: 11
                  green: 15
                entity: sensor.speedtest_upload
          - type: custom:apexcharts-card
            graph_span: 24h
            header:
              show: true
              title: Speedtest
            apex_config:
              responsive:
                - breakpoint: 765
                  options:
                    chart:
                      height: 500px
                - breakpoint: 1025
                  options:
                    chart:
                      height: 400px
                - breakpoint: 10000
                  options:
                    chart:
                      height: auto
              stroke:
                curve: smooth
              chart:
                zoom:
                  enabled: true
                toolbar:
                  show: true
                  tools:
                    zoom: true
                    zoomin: true
                    zoomout: true
                    pan: true
                    reset: true
              plotOptions:
                bar:
                  columnWidth: '50%'
              legend:
                showForSingleSeries: true
            series:
              - entity: sensor.speedtest_download
                show:
                  extremas: true
                stroke_width: 3
                fill_raw: last
                name: Download
                type: line
                group_by:
                  func: raw
                  duration: 30min
              - entity: sensor.speedtest_upload
                show:
                  extremas: true
                stroke_width: 3
                fill_raw: last
                name: Upload
                type: line
                group_by:
                  func: raw
                  duration: 30min
              - entity: sensor.speedtest_ping
                show:
                  extremas: true
                stroke_width: 3
                fill_raw: last
                name: Ping
                type: column
                group_by:
                  func: raw
                  duration: 30min

Note I am using a bash script for speedtest as I find the integration very unreliable so some of the sensor names might differ. This is what it looks like now.


See I am using custom card apexcharts-card as well

3 Likes

Thanks - this worked for me. I’ve seen people complain that it stops working after some time… let’s see I’ll keep an eye our. For now it’s been working for a number of hours.

I am trying to install the speedtest on a RPI 3 running Buster 10. The method above to install speed test for my rpi isn’t working. Error saying package isn’t support and to use the build for your device.

From the link above, I’ve installed the armhf build and placed the speedtest file in /usr/bin.
When I test run the script, I can see the download and upload speed, but error in writing to mqtt. Is there a token I need?

error:

ws1@ws1:~/bin/mqtt/speedtest $ ./speedtest_result.sh
**********************************************************************************************
{"type":"result","timestamp":"2022-03-19T23:22:36Z","ping":{"jitter":0.95099999999999996,"latency":3.4660000000000002},"download":{"bandwidth":11873685,"bytes":42775080,"elapsed":3602},"upload":{"bandwidth":11833866,"bytes":42766320,"elapsed":3614},"packetLoss":0,"isp":"au one net","interface":{"internalIp":"192.168.1.15","name":"eth0","macAddr":"xx:xx:xx:xx:xx:xx","isVpn":false,"externalIp":"xxx.xx.xxx.xxx"},"server":{"id":14623,"host":"speed.coe.ad.jp","port":8080,"name":"IPA CyberLab","location":"Bunkyo","country":"Japan","ip":"xx.xx.xx.xx"},"result":{"id":"xxx-58b4-xxx-8ae1-xxxx","url":"https://www.speedtest.net/result/c/xxx-58b4-xxx-8ae1-xxxxx","persisted":true}}
./speedtest_result.sh: line 18: jq: command not found
./speedtest_result.sh: line 19: jq: command not found
./speedtest_result.sh: line 20: jq: command not found
./speedtest_result.sh: line 21: jq: command not found
./speedtest_result.sh: line 22: jq: command not found


./speedtest_result.sh: line 26: 10**3 * *8/10**6: syntax error: operand expected (error token is "*8/10**6")
./speedtest_result.sh: line 27: 10**3 * *8/10**6: syntax error: operand expected (error token is "*8/10**6")
0.000

{"state":"","attributes":{"time_run":"","ping":"0.000","download":"","upload":""}}

this is the script I have. I’ve only changed the topic.


#!/bin/bash

# Only edit the following setup lines with correct login information

# Mosquitto Broker Details

mqttuser=xxx
mqttpassword=xxx
mqttbroker=192.168.1.20
mqttport=1883

# DO NOT ALTER ANYTHING BELOW THIS LINE

speedtest_result=$(sudo speedtest --format=json --accept-license)
echo "**********************************************************************************************"
echo $speedtest_result

download=$(echo "$speedtest_result" | jq '.download."bandwidth"')
upload=$(echo "$speedtest_result" | jq '.upload."bandwidth"')
ping_server=$(echo "$speedtest_result" | jq '.ping."latency"')
url_test=$(echo "$speedtest_result" | jq '.result."url"' | tr -d \")
time_run=$(echo "$speedtest_result" | jq '.timestamp' | tr -d \")
echo $download $upload $ping_server $time_run
echo $url_test

download=$(printf %.2f "$((10**3 * $download*8/10**6))e-3")
upload=$(printf %.2f "$((10**3 * $upload*8/10**6))e-3")
ping_server=$(printf %.3f "$ping_server")
echo $download $upload $ping_server $time_run
echo $url_test

speedteststring='{"state":"'"$url_test"'","attributes":{"time_run":"'"$time_run"'","ping":"'"$ping_server"'","download":"'"$download"'","upload":"'"$upload"'"}}'
echo $speedteststring
echo "**********************************************************************************************"

# Publish to MQTT Broker

mosquitto_pub -h $mqttbroker -p $mqttport -u "$mqttuser" -P "$mqttpassword" -t house/speedtestresult -m "$speedteststring" -r



So looks like it doesn’t have the jq package installed. You need to install that.

1 Like

Oh shh. I thought jq was a cmd for .sh. Didn’t realized it was a package. Got it working now. Thanks.

1 Like

Hi all, bringing an oldie back to life as it seems the speedtest integration is broken again. Happened sometime on Core 2022.8.1 and still persisted after 8.4, reloaded, removed, re-added same result:

image

Hitting Configure throws this error:

image

When I do this, the systemlog contains this item, consistent with the integration:

Is anybody else experiencing this behavior as of Aug 2022?
Thanks,
Max

1 Like

I’m have the same exact issue Config flow could not be loaded: undefined

Got the same problem here… reloaded the speedtest… and it came up with the same error

Same for me :frowning:

I had exactly the same error after updating to 2022.8.5 earlier today, but now it’s started working again.

The SpeedTest integration seems fragile generally - mine sometimes stops working and is fixed by changing the Test Server to one or other, waiting a few minutes and then changing it back to ‘Auto Detect’. Does anyone else see this and know of a better way to fix it?

yep … i was having same issues as ian… speed test would work for about a week or so… then suddenly stop… error would be server unreachable… selecting different server or reloading usually fixes the problem… but not this time… this time after reload… whole speedtest thing has gone down…

Same issue for me. Upgraded to 2022.8.4 yesterday, same errors as @MaxVonEvil reported above. TBH I’ve never had much luck with Speedtest, it works for a random period of days/weeks then stops and needs a restart.

This integration has been shit for years starting and stopping continually. My script never misses a beat. Using the official speedtest CLI and MQTT to get the data into HA.

2 Likes

SO strange: Now it’s working again…
image

I do not seem to recall it being this unstable.
Could it be Ookla does not liking automated queries as HA does (I run at the default 60 min interval)

That said, anyone aware of any alternative integrations for fast.com or similar?

Hello David, I was wondering if you could share your config/script?

I found it, thanks for this :slight_smile:

See Speedtest Integration No longer loading - #42 by DavidFW1960

1 Like

I’ve now switched to the speedtest CLI on RPi4 (without MQTT) - Add the official speedtest cli - #40 by Britespark.

Seems to be working nicely, but will need a few more hours/days to be certain.

The reason I’m using MQTT is because it’s persistent across restarts without waiting for it to run again

I’m using MQTT for SONOFF devices without really understanding how it works…will have to put that on my learning roadmap :slight_smile: !

2 Likes

Thanks for sharing @DavidFW1960 - had a few hiccups setting it up but soon resolved and looks like a beautiful solution. So far has been solid which the integration sadly is proving not to be! Thanks again

1 Like