[pushover] Add support for Expiring Messages (#15289)

* Add support for Expiring Messages
* Add action variants with TTL parameter

Resolves #15288

---------

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen
2023-10-21 13:34:25 +02:00
committed by GitHub
parent 7d63504eee
commit 089b4152c0
6 changed files with 257 additions and 18 deletions

View File

@@ -40,20 +40,34 @@ The parameter `message` is **mandatory**, the `title` parameter defaults to what
Parameters declared as `@Nullable` are not optional.
One has to pass a `null` value if it should be skipped or the default value for it should be used.
- `sendMessage(String message, @Nullable String title, @Nullable String sound, @Nullable String url, @Nullable String urlTitle, @Nullable String attachment, @Nullable String contentType, @Nullable Integer priority, @Nullable String device)` - This method is used to send a plain text message providing all available parameters.
- `sendMessage(String message, @Nullable String title, @Nullable String sound, @Nullable String url, @Nullable String urlTitle, @Nullable String attachment, @Nullable String contentType, @Nullable Integer priority, @Nullable String device, @Nullable Duration ttl)` - This method is used to send a plain text message providing all available parameters.
- `sendMessage(String message)` - This method is used to send a plain text message with default title.
- `sendMessage(String message, @Nullable String title)` - This method is used to send a plain text message.
- `sendMessage(String message, @Nullable String title, @Nullable Duration ttl)` - This method is used to send a plain text message with TTL.
- `sendHtmlMessage(String message, @Nullable String title)` - This method is used to send a HTML message.
- `sendHtmlMessage(String message, @Nullable String title, @Nullable Duration ttl)` - This method is used to send a HTML message with TTL.
- `sendMonospaceMessage(String message, @Nullable String title)` - This method is used to send a monospace message.
- `sendMonospaceMessage(String message, @Nullable String title, @Nullable Duration ttl)` - This method is used to send a monospace message with TTL.
- `sendAttachmentMessage(String message, @Nullable String title, String attachment, @Nullable String contentType)` - This method is used to send a message with an attachment. It takes a local path or URL to the attachment (parameter `attachment` **mandatory**). Additionally you can pass a data URI scheme to this parameter. Optionally pass a `contentType` to define the content-type of the attachment (default: `image/jpeg` or guessed from image data).
- `sendAttachmentMessage(String message, @Nullable String title, String attachment, @Nullable String contentType, @Nullable Duration ttl)` - This method is used to send a message with an attachment and TTL. See previous method for details.
- `sendURLMessage(String message, @Nullable String title, String url, @Nullable String urlTitle)` - This method is used to send a message with an URL. A supplementary `url` to show with the message and a `urlTitle` for the URL, otherwise just the URL is shown.
- `sendURLMessage(String message, @Nullable String title, String url, @Nullable String urlTitle, @Nullable Duration ttl)` - This method is used to send a message with an URL and TTL. See previous method for details.
- `sendMessageToDevice(String device, String message, @Nullable String title)` - This method is used to send a message to a specific device. Parameter `device` **mandatory** is the name of a specific device (multiple devices may be separated by a comma).
- `sendMessageToDevice(String device, String message, @Nullable String title, @Nullable Duration ttl)` - This method is used to send a message to a specific device with TTL. See previous method for details.
- `sendPriorityMessage(String message, @Nullable String title, @Nullable Integer priority)` - This method is used to send a priority message.
Parameter `priority` is the priority to be used (`-2` = lowest priority, `-1` = low priority, `0` = normal priority, `1` = high priority, `2` = emergency priority; default: `2`).
For priority `2` only, the action returns a `String` value (the `receipt`) if the message was sent successfully, otherwise `null`.
@@ -100,3 +114,27 @@ if( receipt !== null ) {
receipt = null
}
```
:::: tabs
::: tab DSL
```java
val actions = getActions("pushover", "pushover:pushover-account:account")
// send expiring message
actions.sendMessage("Boost has been activated", "Recuperator", Duration.ofHours(1))
```
:::
::: tab JavaScript
```javascript
var pushoverActions = actions.thingActions('pushover', 'pushover:pushover-account:account');
// send expiring message
pushoverActions.sendMessage("Boost has been activated", "Recuperator", time.Duration.ofHours(1));
```
:::
::::