Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[speedtest] Binding for Ookla's Speedtest - Initial contribution #9913

Merged
merged 48 commits into from Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a24c551
Initial Commit - Speedtest Binding
bigbasec Jan 15, 2021
79d775a
Oops
bigbasec Jan 15, 2021
a9f7bf4
Changes to have some of the data points be advanced
bigbasec Jan 15, 2021
990bef9
Changes for selecting a server
bigbasec Jan 18, 2021
0dc63f0
Changes to support a trigger channel to start a speedtest
bigbasec Jan 20, 2021
ed28dc5
Updates to clean things up a bit
bigbasec Jan 20, 2021
a1d10fb
Forgot to make the test channel advanced
bigbasec Jan 20, 2021
d9d357f
Small updates to get ready for PR, also some documentation changes.
bigbasec Jan 22, 2021
67154a4
Fixes wrong input type for server ID
bigbasec Feb 6, 2021
7230e14
Updating trigger test
bigbasec Feb 6, 2021
9524b99
implemented most review findings of initial PR
MikeTheTux Oct 11, 2022
35cc5e9
implemented most review findings of initial PR
MikeTheTux Oct 11, 2022
d59eb07
Added speedtest to original OH3.4.0 pom.xml
Oct 11, 2022
7c0cca4
updated binding version to OH 3.4.0
Oct 11, 2022
0df94a7
fixed naming of Speedtest
Oct 11, 2022
bf8a6bb
added speedtest to bom/openhab-addons/pom.xml
Oct 11, 2022
2623ec3
speedtest -> Speedtest
Oct 11, 2022
d1aea17
fixed compiler warnings
MikeTheTux Oct 11, 2022
eb9ca25
* updated docu
MikeTheTux Oct 12, 2022
70dca73
fixed review findings
MikeTheTux Oct 15, 2022
62bc05f
fixed review findings
MikeTheTux Oct 15, 2022
03c4555
fixed typo
MikeTheTux Oct 15, 2022
5ec3edd
added myself to CODEOWNERS
MikeTheTux Oct 16, 2022
6aa75ea
fixed alphabetic order in pom.xml
MikeTheTux Oct 16, 2022
8840e71
do not refresh if no data yet available
MikeTheTux Oct 22, 2022
6ee0a00
implemented review findings
MikeTheTux Nov 22, 2022
65b9cc1
tabs to blanks in README.md
MikeTheTux Nov 23, 2022
3abd3f9
fixed some (low) SAT warnings
MikeTheTux Nov 23, 2022
af345e9
split between checkFileExists() and checkFileExecutable()
MikeTheTux Nov 23, 2022
5785c22
implemented review finding
MikeTheTux Dec 3, 2022
82e69e6
implemented review findings
MikeTheTux Dec 3, 2022
0374660
fixed NonThreadSafeSingleton
MikeTheTux Dec 3, 2022
c4076ba
NonThreadSafeSingleton
MikeTheTux Dec 3, 2022
b621611
NonThreadSafeSingleton
MikeTheTux Dec 3, 2022
90898e6
update to OH4.0.0 and 2023
MikeTheTux Jan 1, 2023
cfb6f89
re-trigger PR
MikeTheTux Jan 8, 2023
58d209c
reset TRIGGER_TEST channel to OFF
MikeTheTux Jan 22, 2023
3d7e989
binding.xml -> addon.xml
MikeTheTux Jan 22, 2023
3cc604c
fixed all review findings in README.md
MikeTheTux Mar 5, 2023
8bc7886
re-created speedtest.properties
MikeTheTux Mar 5, 2023
dd61841
Merge branch 'openhab:main' into speedtest
MikeTheTux Mar 5, 2023
691acf6
implemented review findings
MikeTheTux Mar 28, 2023
4e9fda5
review com,ents
MikeTheTux Mar 28, 2023
3cdd298
fixed review finding
MikeTheTux Mar 29, 2023
2aa37a2
localized error messages
MikeTheTux Apr 2, 2023
adb92b9
removed last compiler warnings
MikeTheTux Apr 4, 2023
07cd5ac
review comments
MikeTheTux Apr 4, 2023
3b311c3
fixed review finding
MikeTheTux Apr 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -321,6 +321,7 @@
/bundles/org.openhab.binding.sonyaudio/ @freke
/bundles/org.openhab.binding.sonyprojector/ @lolodomo
/bundles/org.openhab.binding.souliss/ @lucacalcaterra @fazioa
/bundles/org.openhab.binding.speedtest/ @MikeTheTux
/bundles/org.openhab.binding.spotify/ @Hilbrand
/bundles/org.openhab.binding.squeezebox/ @digitaldan @mhilbush
/bundles/org.openhab.binding.surepetcare/ @renescherer @HerzScheisse
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Expand Up @@ -1601,6 +1601,11 @@
<artifactId>org.openhab.binding.souliss</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.speedtest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.spotify</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.speedtest/NOTICE
@@ -0,0 +1,13 @@
This content is produced and maintained by the openHAB project.

* Project home: https://www.openhab.org

== Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.

== Source Code

https://github.com/openhab/openhab-addons
118 changes: 118 additions & 0 deletions bundles/org.openhab.binding.speedtest/README.md
@@ -0,0 +1,118 @@
# Speedtest Binding

The Speedtest Binding can be used to perform a network speed test for your openHAB instance.
It is based on the command line interface (CLI) version of Ookla's Speedtest (https://www.speedtest.net/apps/cli).

The Ookla CLI Speedtest application MUST be installed on your openHAB instance when using the Speedtest Binding.

jlaur marked this conversation as resolved.
Show resolved Hide resolved
## Why Ookla's Speedtest?

Fully supported and maintained by Ookla with the latest Speedtest technology for best results:

- Consistent measurement, even on high bandwidth
- Consistent measurement, very much independent from the performance of the host system

## What functionality does Ookla's Speedtest offer?
lsiepel marked this conversation as resolved.
Show resolved Hide resolved

The Speedtest Binding is using the following functionality, provided by Ookla's Speedtest:

- Output of an accurate timestamp per measurement
- Output of Ping time and Jitter
- Output of Bandwidth, transferred Bytes and elapsed time for Down-/Upload
- Output of the used interface with Internal/External IP, MAC Address and the Internet Service Provider (ISP)
- Output of a result ID and a result URL
- Output of the used Server and location the Speedtest was run against
- Possibility to pre-select a server used for testing

## What interfaces does the Speedtest Binding offer?

The Speedtest Binding provides the Ookla's Speedtest functionality via the following openHAB interface:

- Execute Speedtest time based or triggered
- Provide results via openHAB Channels
- List available Ookla Speedtest servers that can be used for testing (optional)

## Ookla License and Privacy Terms

When using this binding, you automatically accept the license and privacy terms of Ookla's Speedtest.
You can find the latest version of those terms at the following webpages:

- https://www.speedtest.net/about/eula
- https://www.speedtest.net/about/terms
- https://www.speedtest.net/about/privacy

## Supported Things

Speedtest thing.

jlaur marked this conversation as resolved.
Show resolved Hide resolved
## Binding Configuration

For this binding to work, you MUST install Ookla's Speedtest command line tool (`speedtest` or `speedtest.exe`).
It will not work with other versions like `speedtest-cli` or other `speedtest` variants.

To install Ookla's version of Speedtest, head to https://www.speedtest.net/apps/cli and follow the instructions for your Operating System.

jlaur marked this conversation as resolved.
Show resolved Hide resolved
## Thing Configuration

| Parameter | Description | Default |
|-------------------|------------------------------------------------------------------------------------------------------------------------------|---------|
| `refreshInterval` | How often to test network speed, in minutes | `60` |
| `execPath` | The path of the Ookla Speedtest executable.<br/>Linux machines may leave this blank and it defaults to `/usr/bin/speedtest`. | |
| `serverID` | Optional: A specific server that shall be used for testing. You can pick the server ID from the "Thing Properties".<br/>If this is left blank the best option will be selected by Ookla. | |

The `refreshInterval` parameter can also be set to `0` which means "Do not test automatically".
This can be used if you want to use the "Trigger Test" channel in order to test via rules, or an item instead.

Ensure that the user that openHAB is running with, has the permissions to access and execute the executable.

lsiepel marked this conversation as resolved.
Show resolved Hide resolved
## Properties

| Property | Description |
|---------------------|------------------------------------------------------------------------------------------------------------|
| Server List 1...10 | A List of Ookla Speedtest servers that can be used in order to specify a specific server for the Speedtest.<br/>Configure the Server ID via the `serverID` Thing Configuration Parameter. |

## Channels

| Channel | Type | Description |
|-----------------------|---------------------------|-------------------------------------------------------------------|
| `server` | `String` | The remote server that the Speedtest was run against |
| `pingJitter` | `Number:Time` | Ping Jitter - the variation in the response time |
| `pingLatency` | `Number:Time` | Ping Latency - the reaction time of your internet connection |
| `downloadBandwidth` | `Number:DataTransferRate` | Download bandwidth, e.g. in Mbit/s |
| `downloadBytes` | `Number:DataAmount` | Amount of data that was used for the last download bandwidth test |
| `downloadElapsed` | `Number:Time` | Time spent for the last download bandwidth test |
| `uploadBandwidth` | `Number:DataTransferRate` | Upload bandwidth, e.g. in Mbit/s |
| `uploadBytes` | `Number:DataAmount` | Amount of data that was used for the last upload bandwidth test |
| `uploadElapsed` | `Number:Time` | Time spent for the last upload bandwidth test |
| `isp` | `String` | Your Internet Service Provider (ISP) as calculated by Ookla |
| `interfaceInternalIp` | `String` | IP address of the internal interface that was used for the test |
| `interfaceExternalIp` | `String` | IP address of the external interface that was used for the test |
| `resultUrl` | `String` | The URL to the Speedtest results in HTML on the Ookla webserver |
| `triggerTest` | `Switch` | Trigger in order to run Speedtest manually |

jlaur marked this conversation as resolved.
Show resolved Hide resolved
## Full Example

### Thing File

```java
Thing speedtest:speedtest:myspeedtest "Ookla Speedtest" [ execPath="/usr/bin/speedtest", refreshInterval=60 ]
```

### Item File

```java
String Speedtest_Server "Server" { channel="speedtest:speedtest:myspeedtest:server" }
Number:Time Speedtest_Ping_Jitter "Ping Jitter" { channel="speedtest:speedtest:myspeedtest:pingJitter" }
Number:Time Speedtest_Ping_Latency "Ping Latency" { channel="speedtest:speedtest:myspeedtest:pingLatency" }
Number:DataTransferRate Speedtest_Download_Bandwith "Download Bandwith" { channel="speedtest:speedtest:myspeedtest:downloadBandwidth" }
Number:DataAmount Speedtest_Download_Bytes "Download Bytes" { channel="speedtest:speedtest:myspeedtest:downloadBytes" }
Number:Time Speedtest_Download_Elapsed "Download Elapsed" { channel="speedtest:speedtest:myspeedtest:downloadElapsed" }
Number:DataTransferRate Speedtest_Upload_Bandwith "Upload Bandwith" { channel="speedtest:speedtest:myspeedtest:uploadBandwidth" }
Number:DataAmount Speedtest_Upload_Bytes "Upload Bytes" { channel="speedtest:speedtest:myspeedtest:uploadBytes" }
Number:Time Speedtest_Upload_Elapsed "Upload Elapsed" { channel="speedtest:speedtest:myspeedtest:uploadElapsed" }
String Speedtest_ISP "ISP" { channel="speedtest:speedtest:myspeedtest:isp" }
String Speedtest_Interface_InternalIP "Internal IP Address" { channel="speedtest:speedtest:myspeedtest:interfaceInternalIp" }
String Speedtest_Interface_ExternalIP "External IP Address" { channel="speedtest:speedtest:myspeedtest:interfaceExternalIp" }
String Speedtest_ResultURL "Result URL" { channel="speedtest:speedtest:myspeedtest:resultUrl" }
Switch Speedtest_TriggerTest "Trigger Test" { channel="speedtest:speedtest:myspeedtest:triggerTest" }
```
17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.speedtest/pom.xml
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>4.0.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.speedtest</artifactId>

<name>openHAB Add-ons :: Bundles :: Speedtest Binding</name>

</project>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.speedtest-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>

<feature name="openhab-binding-speedtest" description="Speedtest Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.speedtest/${project.version}</bundle>
</feature>
</features>
@@ -0,0 +1,71 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/

package org.openhab.binding.speedtest.internal;

import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;

/**
* The {@link SpeedtestBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Brian Homeyer - Initial contribution
*/
@NonNullByDefault
public class SpeedtestBindingConstants {

private static final String BINDING_ID = "speedtest";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_SPEEDTEST = new ThingTypeUID(BINDING_ID, "speedtest");

// Config
public static final String REFRESH_INTERVAL = "refreshInterval";
public static final String EXEC_PATH = "execPath";
public static final String SPEEDTEST_VERSION = "speedTestVersion";
public static final String SERVER_ID = "serverID";

// Channels
public static final String SERVER = "server";
public static final String PING_JITTER = "pingJitter";
public static final String PING_LATENCY = "pingLatency";
public static final String DOWNLOAD_BANDWIDTH = "downloadBandwidth";
public static final String DOWNLOAD_BYTES = "downloadBytes";
public static final String DOWNLOAD_ELAPSED = "downloadElapsed";
public static final String UPLOAD_BANDWIDTH = "uploadBandwidth";
public static final String UPLOAD_BYTES = "uploadBytes";
public static final String UPLOAD_ELAPSED = "uploadElapsed";
public static final String ISP = "isp";
public static final String INTERFACE_INTERNALIP = "interfaceInternalIp";
public static final String INTERFACE_EXTERNALIP = "interfaceExternalIp";
public static final String RESULT_URL = "resultUrl";
public static final String TRIGGER_TEST = "triggerTest";

public static final String PROPERTY_SERVER_LIST1 = "Server List 1";
public static final String PROPERTY_SERVER_LIST2 = "Server List 2";
public static final String PROPERTY_SERVER_LIST3 = "Server List 3";
public static final String PROPERTY_SERVER_LIST4 = "Server List 4";
public static final String PROPERTY_SERVER_LIST5 = "Server List 5";
public static final String PROPERTY_SERVER_LIST6 = "Server List 6";
public static final String PROPERTY_SERVER_LIST7 = "Server List 7";
public static final String PROPERTY_SERVER_LIST8 = "Server List 8";
public static final String PROPERTY_SERVER_LIST9 = "Server List 9";
public static final String PROPERTY_SERVER_LIST10 = "Server List 10";

public static final Set<String> SUPPORTED_CHANNEL_IDS = Set.of(SERVER, PING_JITTER, PING_LATENCY,
DOWNLOAD_BANDWIDTH, DOWNLOAD_BYTES, DOWNLOAD_ELAPSED, UPLOAD_BANDWIDTH, UPLOAD_BYTES, UPLOAD_ELAPSED, ISP,
INTERFACE_INTERNALIP, INTERFACE_EXTERNALIP, RESULT_URL);
}
@@ -0,0 +1,29 @@
/**
* Copyright (c) 2010-2023 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/

package org.openhab.binding.speedtest.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link SpeedtestConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Brian Homeyer - Initial contribution
*/
@NonNullByDefault
public class SpeedtestConfiguration {
public int refreshInterval = 60;
public String execPath = "";
public String serverID = "";
public String speedTestVersion = "";
}