I am using HA in Docker on Raspberry Pi 3.
Since last few months I have been using “speedtest-cli” instead of “speedtestdotnet” integration.
The reasons of this are:
- I need more information which can be provided by “speedtest-cli”: IP address & ISP name.
- There is a DualWAN setup in my router, so I have 2 providers. I wanted to monitor speed for both providers; for this I made routing rules in the router like “host #1 uses primary interface” (i.e. ISP #1), “host #2 uses secondary interface” (i.e. ISP #2). Monitoring can be achieved by running speedtest on both hosts.
“host #1” is a Raspberry Pi 3 with HA.
“host #2” is another Raspberry Pi 3 (basically used for Kodi).
“speedtest-cli” is taken from here - GitHub - sivel/speedtest-cli: Command line interface for testing internet bandwidth using speedtest.net.
For local monitoring (i.e. on “host #1”) I am using this sensor:
sensor:
- platform: command_line
name: "Speedtest (local)"
command: "/config/utils/speedtest-cli"
value_template: "{{ ..... }}"
command_timeout: 120
scan_interval: 999999
For remote monitoring (i.e on “host #2”) I am using this sensor:
- platform: command_line
name: "Speedtest (remote)"
command: !secret ssh_speedtest_remote_command
value_template: "{{ ..... }}"
command_timeout: 120
scan_interval: 999999
The sensors are updated every 1 hour (in different time like “at 00:30” for local, “at 00:40” for remote) by automations.
Then sensors’ values are parsed in another sensors to get “DL speed”, “UL speed”, “Ping”, “ISP name”, “IP address”.
Now the important part.
First for the local sensor the command line was this: command: "/config/utils/speedtest-cli"
In the HA folder I made a subfolder with that “speedtest-cli” program and added this subfolder in the “configuration.yaml” file:
allowlist_external_dirs:
- /config
- /config/utils
- /config/lovelace
And this setup worked so far.
Some time ago because of unknown reasons the local sensor stopped working - the sensor was not updated, there was errors in the log:
Logger: homeassistant.components.command_line
Source: components/command_line/__init__.py:41
Integration: command_line (documentation, issues)
First occurred: 6:46:50 PM (1 occurrences)
Last logged: 6:46:50 PM
Command failed: /config/utils/speedtest-cli
I thought that these errors were caused by a lack of RAM - recently I started experimenting with VSCode in Docker which made my setup (Raspberry Pi 3, 1GB) very unstable (freezes sometimes).
Then I found another Speedtest CLI program - this is an official OOKLA CLI program (Speedtest CLI - Internet connection measurement for developers).
Tried to install and test it - this program seems to work faster and gives higher results))).
Now about the problem:
I decided to use that OOKLA speedtest program instead of the “speedtest-cli”.
What I did is:
- Changed the sensor:
command: "/config/utils/speedtest"
- Placed the “speedtest” file into the “utils” folder.
- Changed a code for parsing the output.
But the result is negative - still I see that errors in the log.
What causes these errors?
The most strange thing:
In terminal, the “speedtest” program is started properly - but only if selected explicitly:
sudo ./HA/utils/speedtest
Speedtest by Ookla
Server: XXXXXXXX - Moscow (id = 14190)
ISP: XXXXXXXX
Latency: 1.60 ms (0.09 ms jitter)
Download: 93.64 Mbps [====| ] 23%
.....
If the path is not specified, then strangely the “speedtest-cli” is started:
speedtest
Retrieving speedtest.net configuration...
Testing from XXXX (XXX.XXX.XXX.XXX)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by XXXXX (Moscow) [14.94 km]: 5.069 ms
Testing download speed............
I cannot understand why the “speedtest-cli” is started instead of the new “speedtest” program.