Still no luck. With all settings I am not getting any data in the logs. Wonder if the command line sensor will wait long enough for the test to complete. Timeout is enough time for the test to complete.
When speedtest is executed the first time is prompts for two license acceptances. I opened a terminal as the homeassistant user and accepted the terms before the command worked for me.
I think my issue is related to running Hassio in docker - think it’s an access issue outside of docker that stops the command from running properly. Even using your code I still get nothing back.
I tried running the command as a shell command so that I could pipe the speedtest command and accept the terms and conditions but that didn’t work either.
Shame that the current sensor gives me a result about 50% lower than the CLI command gives.
I tried running console commands in portainer but they would not work. If I run the command speedtest, which uses the built in version, that runs slow as well. Think the main integration needs to be updated. Will raise an issue tomorrow if there isn’t one already.
I use hassio on an RP3 and have the same problem with speedtest.net.
I tried the test with the ethernet port and a gigabit usb adapter, but the download remains below 50 mbit/s (for comparison: i reach 200 mbit/s with my notebook). Can’t test the hint with the terminal and command line, because of hassio (=no hassbian).
The Pi3 shares the ethernet port with USB so it will be slower than FE (100mbit) speeds. The 3B+ can go higher and I was getting the full 200mbit of my connection up to about 3 months ago before it started playing up. My new Pi4 has the same issue so I use the Fast.com integration for my download speed and the Speedtest integration for upload and latency.
A bit improved way is to develop a wrapper around the speedtest-cli so that we get output in flat json so that we can read all interesting attributes in single command_line sensor update:
Not sure as I’m using HA Core installation. But here is a post I’ve found on how to access HA command line in docker.
Alternatively you could run the speedtest-cli in the host or another vm etc and run the command_line sensor from there e.g. via ssh e.g. like that: 'sshpass -p "yourpass" ssh -o StrictHostKeyChecking=no user_id@ip_address "python3.8 speedtest_script.py"' - with proper names, paths, python version etc.
Hi @adorobis
i use your script but i have an error with parsing json result of your python script
Unable to parse output as JSON: Running Speedtest Stdout: {“type”:“result”,“timestamp”:“2022-02-20T09:20:02Z”,“ping”:{“jitter”:0.157,“latency”:2.5649999999999999},“download”:{“bandwidth”:104044380,“bytes”:534511716,“elapsed”:5112},“upload”:{“bandwidth”:73438235,“bytes”:841584580,“elapsed”:12215},“packetLoss”:0,“isp”:“Orange”,“interface”:{“internalIp”:“2a01:cb19:7b9:de00:cf9b:8af5:6490:fdfc”,“name”:“enp0s3”,“macAddr”:“08:00:27:34:06:C2”,“isVpn”:false,“externalIp”:“2a01:cb19:7b9:de00:cf9b:8af5:6490:fdfc”},“server”:{“id”:29542,“host”:“bordeaux3.speedtest.orange.fr”,“port”:8080,“name”:“ORANGE FRANCE”,“location”:“Bordeaux”,“country”:“France”,“ip”:“2a01:cb19:2004:4000::3”},“result”:{“id”:“95f65d94-aa71-4c87-9b91-af11674bf8b0”,“url”:“Speedtest by Ookla - The Global Broadband Speed Test”:true}}
Not sure what’s happening as the above json looks formatted already, instead of "" there are “” characters. Try to run speedtest cli from command line and see if that is what you get. The command that the python script executes is:
{"type":"result","timestamp":"2022-02-20T10:09:08Z","ping":{"jitter":1.284,"latency":2.161},"download":{"bandwidth":68744699,"bytes":331946224,"elapsed":4811},"upload":{"bandwidth":14055341,"bytes":214469729,"elapsed":14616},"packetLoss":0,"isp":"Orange Swiatlowod","interface":{"internalIp":"10.144.1.20","name":"em0","macAddr":"68:05:CA:C6:D2:06","isVpn":false,"externalIp":"83.29.138.82"},"server":{"id":7175,"name":"Orange Polska S.A.","location":"Krakow","country":"Poland","host":"kra-o1.speedtest.orange.pl","port":8080,"ip":"80.50.113.170"},"result":{"id":"4602136a-a83d-4a3c-bbf3-0eb8f3521062","url":"https://www.speedtest.net/result/c/4602136a-a83d-4a3c-bbf3-0eb8f3521062"}}