From 047ae89aaf2c95cb97ef04ed4cdd2f9d5af31311 Mon Sep 17 00:00:00 2001 From: ridiekel Date: Wed, 9 Jun 2021 07:12:30 +0200 Subject: [PATCH] [pushover] Provides the ability to specify a timeout in the config (#10817) * Provides the ability to specify a timeout in the config, instead of using hardcoded 10 seconds. Signed-off-by: Geroen Dierckx --- bundles/org.openhab.binding.pushover/README.md | 1 + .../internal/config/PushoverAccountConfiguration.java | 1 + .../internal/connection/PushoverAPIConnection.java | 3 ++- .../src/main/resources/OH-INF/config/config.xml | 7 +++++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.pushover/README.md b/bundles/org.openhab.binding.pushover/README.md index 171968968..314c846c3 100644 --- a/bundles/org.openhab.binding.pushover/README.md +++ b/bundles/org.openhab.binding.pushover/README.md @@ -21,6 +21,7 @@ You are able to create multiple instances of this Thing to broadcast to differen | `sound` | text | The default notification sound on target device (default: `default`) (see [supported notification sounds](https://pushover.net/api#sounds)). | | `retry` | integer | The retry parameter specifies how often (in seconds) the Pushover servers will send the same notification to the user (default: `300`). **advanced** | | `expire` | integer | The expire parameter specifies how long (in seconds) your notification will continue to be retried (default: `3600`). **advanced** | +| `timeout` | integer | The timeout parameter specifies maximum number of seconds a request to Pushover can take. **advanced** | The `retry` and `expire` parameters are only used for emergency-priority notifications. diff --git a/bundles/org.openhab.binding.pushover/src/main/java/org/openhab/binding/pushover/internal/config/PushoverAccountConfiguration.java b/bundles/org.openhab.binding.pushover/src/main/java/org/openhab/binding/pushover/internal/config/PushoverAccountConfiguration.java index 8622d686e..4a39c0022 100644 --- a/bundles/org.openhab.binding.pushover/src/main/java/org/openhab/binding/pushover/internal/config/PushoverAccountConfiguration.java +++ b/bundles/org.openhab.binding.pushover/src/main/java/org/openhab/binding/pushover/internal/config/PushoverAccountConfiguration.java @@ -31,4 +31,5 @@ public class PushoverAccountConfiguration { public String sound = DEFAULT_SOUND; public int retry = 300; public int expire = 3600; + public int timeout = 10; } diff --git a/bundles/org.openhab.binding.pushover/src/main/java/org/openhab/binding/pushover/internal/connection/PushoverAPIConnection.java b/bundles/org.openhab.binding.pushover/src/main/java/org/openhab/binding/pushover/internal/connection/PushoverAPIConnection.java index 8e8f6e820..8f84241d4 100644 --- a/bundles/org.openhab.binding.pushover/src/main/java/org/openhab/binding/pushover/internal/connection/PushoverAPIConnection.java +++ b/bundles/org.openhab.binding.pushover/src/main/java/org/openhab/binding/pushover/internal/connection/PushoverAPIConnection.java @@ -134,7 +134,8 @@ public class PushoverAPIConnection { throws PushoverCommunicationException, PushoverConfigurationException { logger.trace("Pushover request: {} - URL = '{}'", httpMethod, url); try { - final Request request = httpClient.newRequest(url).method(httpMethod).timeout(10, TimeUnit.SECONDS); + final Request request = httpClient.newRequest(url).method(httpMethod).timeout(config.timeout, + TimeUnit.SECONDS); if (body != null) { if (logger.isTraceEnabled()) { diff --git a/bundles/org.openhab.binding.pushover/src/main/resources/OH-INF/config/config.xml b/bundles/org.openhab.binding.pushover/src/main/resources/OH-INF/config/config.xml index 8e74c7261..09a61f162 100644 --- a/bundles/org.openhab.binding.pushover/src/main/resources/OH-INF/config/config.xml +++ b/bundles/org.openhab.binding.pushover/src/main/resources/OH-INF/config/config.xml @@ -48,6 +48,13 @@ The expire parameter specifies how long your notification will continue to be retried. 3600 + + true + + The timeout parameter specifies maximum number of seconds a request to Pushover can + take. + 10 +