| `retry` | integer | The retry parameter specifies how often (in seconds) the Pushover servers will send the same emergency-priority notification to the user (default: `300`). **advanced** |
| `expire` | integer | The expire parameter specifies how long (in seconds) your emergency-priority 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** |
+| `idleTimeout` | integer | The idle-timeout parameter specifies maximum number of seconds a connection with Pushover can be idle (default: `300`). **advanced** |
## Channels
For other priorities, the action always returns an empty `String`.
- `cancelPriorityMessage(String receipt)` - This method is used to cancel an emergency priority message.
-
The action returns a `Boolean` value to indicate if the message was cancelled successfully or not.
## Full Example
@NonNullByDefault
public class PushoverBindingConstants {
- private static final String BINDING_ID = "pushover";
+ public static final String BINDING_ID = "pushover";
public static final ThingTypeUID PUSHOVER_ACCOUNT = new ThingTypeUID(BINDING_ID, "pushover-account");
public int retry = 300;
public int expire = 3600;
public int timeout = 10;
+ public int idleTimeout = 300;
}
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
+import org.openhab.binding.pushover.internal.PushoverBindingConstants;
import org.openhab.binding.pushover.internal.handler.PushoverAccountHandler;
import org.openhab.core.io.net.http.HttpClientFactory;
+import org.openhab.core.io.net.http.HttpClientInitializationException;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
import org.openhab.core.thing.binding.ThingHandler;
import org.openhab.core.thing.binding.ThingHandlerFactory;
+import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
@Activate
public PushoverHandlerFactory(final @Reference HttpClientFactory httpClientFactory) {
- this.httpClient = httpClientFactory.getCommonHttpClient();
+ httpClient = httpClientFactory.createHttpClient(PushoverBindingConstants.BINDING_ID);
+ try {
+ httpClient.start();
+ } catch (final Exception e) {
+ throw new HttpClientInitializationException("Could not start HttpClient", e);
+ }
+ }
+
+ @Override
+ protected void deactivate(final ComponentContext componentContext) {
+ try {
+ httpClient.stop();
+ } catch (final Exception e) {
+ // Eat http client stop exception.
+ } finally {
+ super.deactivate(componentContext);
+ }
}
@Override
if (configValid) {
updateStatus(ThingStatus.UNKNOWN);
-
+ httpClient.setIdleTimeout(config.idleTimeout * 1000);
connection = new PushoverAPIConnection(httpClient, config);
scheduler.submit(this::asyncValidateUser);
}
take.</description>
<default>10</default>
</parameter>
+ <parameter name="idleTimeout" type="integer" min="0" max="10800" unit="s">
+ <advanced>true</advanced>
+ <label>Idle Timeout</label>
+ <description>The idle-timeout parameter specifies maximum number of seconds a connection with Pushover can be idle.</description>
+ <default>300</default>
+ </parameter>
</config-description>
</config-description:config-descriptions>
thing-type.config.pushover.pushover-account.format.option.none = None
thing-type.config.pushover.pushover-account.format.option.html = HTML
thing-type.config.pushover.pushover-account.format.option.monospace = monospace
+thing-type.config.pushover.pushover-account.idleTimeout.label = Idle Timeout
+thing-type.config.pushover.pushover-account.idleTimeout.description = The idle-timeout parameter specifies maximum number of seconds a connection with Pushover can be idle.
thing-type.config.pushover.pushover-account.retry.label = Retry
thing-type.config.pushover.pushover-account.retry.description = The retry parameter specifies how often the Pushover servers will send the same notification to the user.
thing-type.config.pushover.pushover-account.sound.label = Notification Sound