diff --git a/bundles/org.openhab.binding.pushsafer/README.md b/bundles/org.openhab.binding.pushsafer/README.md index 727cd9e6c33..3ef0753913a 100644 --- a/bundles/org.openhab.binding.pushsafer/README.md +++ b/bundles/org.openhab.binding.pushsafer/README.md @@ -29,6 +29,8 @@ You are able to create multiple instances of this Thing to broadcast to differen | `confirm` | integer | Integer 10-10800 (10s steps) Time in seconds after which a message should be sent again before it is confirmed. (default: `0`). **advanced** | | `time2live` | integer | Time in minutes, after a message automatically gets purged (default: `0`). **advanced** | | `answer` | integer | 1 = enables reply to push notifications (default: `0`). **advanced** | +| `answeroptions` | text | specify predefined answer options divided by a pipe character, e.g. Yes\|No\|Maybe **advanced** | +| `answerforce` | integer | 1 = force an answer. The user will be prompted to answer, the message will be open directly. (default: `0`). **advanced** | The `retry` and `expire` parameters are only used for emergency-priority notifications. diff --git a/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/PushsaferBindingConstants.java b/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/PushsaferBindingConstants.java index 19f50594e13..b94eeeaba53 100644 --- a/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/PushsaferBindingConstants.java +++ b/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/PushsaferBindingConstants.java @@ -39,6 +39,8 @@ public class PushsaferBindingConstants { public static final String DEFAULT_VIBRATION = "1"; public static final int DEFAULT_CONFIRM = 0; public static final boolean DEFAULT_ANSWER = false; + public static final String DEFAULT_ANSWEROPTIONS = ""; + public static final boolean DEFAULT_ANSWERFORCE = false; public static final int DEFAULT_TIME2LIVE = 0; public static final String DEFAULT_TITLE = "openHAB"; } diff --git a/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/config/PushsaferAccountConfiguration.java b/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/config/PushsaferAccountConfiguration.java index 7e13757f36d..9b98f35ddde 100644 --- a/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/config/PushsaferAccountConfiguration.java +++ b/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/config/PushsaferAccountConfiguration.java @@ -35,6 +35,8 @@ public class PushsaferAccountConfiguration { public String url = DEFAULT_URL; public String urlTitle = DEFAULT_URLTITLE; public boolean answer = DEFAULT_ANSWER; + public String answeroptions = DEFAULT_ANSWEROPTIONS; + public boolean answerforce = DEFAULT_ANSWERFORCE; public int confirm = DEFAULT_CONFIRM; public int time2live = DEFAULT_TIME2LIVE; public String vibration = DEFAULT_VIBRATION; diff --git a/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/connection/PushsaferMessageBuilder.java b/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/connection/PushsaferMessageBuilder.java index 712bf631d11..e46bf729fa3 100644 --- a/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/connection/PushsaferMessageBuilder.java +++ b/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/connection/PushsaferMessageBuilder.java @@ -57,6 +57,8 @@ public class PushsaferMessageBuilder { private static final String MESSAGE_KEY_SOUND = "s"; private static final String MESSAGE_KEY_TIME2LIVE = "l"; private static final String MESSAGE_KEY_ANSWER = "a"; + private static final String MESSAGE_KEY_ANSWEROPTIONS = "ao"; + private static final String MESSAGE_KEY_ANSWERFORCE = "af"; private static final String MESSAGE_KEY_CONFIRM = "cr"; private static final String MESSAGE_KEY_ATTACHMENT = "p"; public static final String MESSAGE_KEY_HTML = "html"; @@ -90,6 +92,8 @@ public class PushsaferMessageBuilder { private int confirm; private int time2live; private boolean answer; + private @Nullable String answeroptions; + private boolean answerforce; private @Nullable String color; private @Nullable String vibration; private @Nullable String attachment; @@ -181,6 +185,16 @@ public class PushsaferMessageBuilder { return this; } + public PushsaferMessageBuilder withAnswerForce(boolean answerforce) { + this.answerforce = answerforce; + return this; + } + + public PushsaferMessageBuilder withAnswerOptions(String answeroptions) { + this.answeroptions = answeroptions; + return this; + } + public PushsaferMessageBuilder withTime2live(int time2live) { this.time2live = time2live; return this; @@ -307,6 +321,10 @@ public class PushsaferMessageBuilder { body.addFieldPart(MESSAGE_KEY_ANSWER, new StringContentProvider(String.valueOf(answer)), null); + body.addFieldPart(MESSAGE_KEY_ANSWEROPTIONS, new StringContentProvider(String.valueOf(answeroptions)), null); + + body.addFieldPart(MESSAGE_KEY_ANSWERFORCE, new StringContentProvider(String.valueOf(answerforce)), null); + body.addFieldPart(MESSAGE_KEY_TIME2LIVE, new StringContentProvider(String.valueOf(time2live)), null); String attachment = this.attachment; if (attachment != null) { diff --git a/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/handler/PushsaferAccountHandler.java b/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/handler/PushsaferAccountHandler.java index 64c607fbc50..259430e018a 100644 --- a/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/handler/PushsaferAccountHandler.java +++ b/bundles/org.openhab.binding.pushsafer/src/main/java/org/openhab/binding/pushsafer/internal/handler/PushsaferAccountHandler.java @@ -182,6 +182,14 @@ public class PushsaferAccountHandler extends BaseThingHandler { if (DEFAULT_ANSWER != config.answer) { builder.withAnswer(config.answer); } + // add answeroptions if defined + if (DEFAULT_ANSWEROPTIONS != config.answeroptions) { + builder.withAnswerOptions(config.answeroptions); + } + // add answerforce if defined + if (DEFAULT_ANSWERFORCE != config.answerforce) { + builder.withAnswerForce(config.answerforce); + } // add time2live if defined if (DEFAULT_TIME2LIVE != config.time2live) { builder.withTime2live(config.time2live); diff --git a/bundles/org.openhab.binding.pushsafer/src/main/resources/OH-INF/config/config.xml b/bundles/org.openhab.binding.pushsafer/src/main/resources/OH-INF/config/config.xml index 6f362b8b3c5..f5247e7177a 100644 --- a/bundles/org.openhab.binding.pushsafer/src/main/resources/OH-INF/config/config.xml +++ b/bundles/org.openhab.binding.pushsafer/src/main/resources/OH-INF/config/config.xml @@ -94,6 +94,17 @@ true = Enable reply to push notifications, false otherwise. false + + true + + Specify predefined answer options divided by a pipe character, e.g. Yes|No|Maybe + + + true + + true = force an answer. The user will be prompted to answer, the message will be open directly. + false + diff --git a/bundles/org.openhab.binding.pushsafer/src/main/resources/OH-INF/i18n/pushsafer.properties b/bundles/org.openhab.binding.pushsafer/src/main/resources/OH-INF/i18n/pushsafer.properties index c166151f736..aa78b901c92 100644 --- a/bundles/org.openhab.binding.pushsafer/src/main/resources/OH-INF/i18n/pushsafer.properties +++ b/bundles/org.openhab.binding.pushsafer/src/main/resources/OH-INF/i18n/pushsafer.properties @@ -12,6 +12,10 @@ thing-type.pushsafer.pushsafer-account.description = Provides access to the Push thing-type.config.pushsafer.pushsafer-account.answer.label = Answer thing-type.config.pushsafer.pushsafer-account.answer.description = true = Enable reply to push notifications, false otherwise. +thing-type.config.pushsafer.pushsafer-account.answeroptions.label = Answer Options +thing-type.config.pushsafer.pushsafer-account.answeroptions.description = specify predefined answer options divided by a pipe character, e.g. Yes|No|Maybe. +thing-type.config.pushsafer.pushsafer-account.answerforce.label = Answer Force +thing-type.config.pushsafer.pushsafer-account.answerforce.description = true = force an answer. The user will be prompted to answer, the message will be open directly. thing-type.config.pushsafer.pushsafer-account.apikey.label = Private or Alias Key thing-type.config.pushsafer.pushsafer-account.apikey.description = Your Private or Alias to access the Pushsafer Message API. thing-type.config.pushsafer.pushsafer-account.color.label = Icon Color diff --git a/bundles/org.openhab.binding.pushsafer/src/main/resources/OH-INF/i18n/pushsafer_de.properties b/bundles/org.openhab.binding.pushsafer/src/main/resources/OH-INF/i18n/pushsafer_de.properties index 4aa0a86f46e..dbf72a4a77e 100644 --- a/bundles/org.openhab.binding.pushsafer/src/main/resources/OH-INF/i18n/pushsafer_de.properties +++ b/bundles/org.openhab.binding.pushsafer/src/main/resources/OH-INF/i18n/pushsafer_de.properties @@ -12,6 +12,10 @@ thing-type.pushsafer.pushsafer-account.description = Ermöglicht den Zugriff auf thing-type.config.pushsafer.pushsafer-account.answer.label = Antwort thing-type.config.pushsafer.pushsafer-account.answer.description = true \= Aktiviere Antworten auf Push-Benachrichtigungen, sonst false. +thing-type.config.pushsafer.pushsafer-account.answeroptions.label = Antwort Optionen +thing-type.config.pushsafer.pushsafer-account.answeroptions.description = vordefinierte Antwortmöglichkeiten getrennt mit einem Pipe-Zeichen z.B. Ja|Nein|Vielleicht. +thing-type.config.pushsafer.pushsafer-account.answerforce.label = Antwort erzwingen +thing-type.config.pushsafer.pushsafer-account.answerforce.description = true \= erzwingt eine Antwort, der Nutzer wird aufgefordert zu antworten, die Nachricht wird direkt geöffnet, sonst false. thing-type.config.pushsafer.pushsafer-account.apikey.label = Privater Schlüssel thing-type.config.pushsafer.pushsafer-account.apikey.description = Ihr privater Schlüssel für den Zugriff auf die Pushsafer Nachrichten-API. thing-type.config.pushsafer.pushsafer-account.color.label = Icon-Farbe