From 2535c6ada22dfd2bbe476601204c2bc56a1a3611 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Tue, 1 Oct 2024 14:12:22 +0200 Subject: [PATCH] Provide JavaScript examples (#17490) Signed-off-by: Jacob Laursen --- .../org.openhab.binding.pushover/README.md | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/bundles/org.openhab.binding.pushover/README.md b/bundles/org.openhab.binding.pushover/README.md index 712f9173fa1ca..afcbd476fc27b 100644 --- a/bundles/org.openhab.binding.pushover/README.md +++ b/bundles/org.openhab.binding.pushover/README.md @@ -87,12 +87,34 @@ Thing pushover:pushover-account:account [ apikey="APP_TOKEN", user="USER_KEY" ] demo.rules: +:::: tabs + +::: tab DSL + ```java val actions = getActions("pushover", "pushover:pushover-account:account") // send HTML message actions.sendHtmlMessage("Hello World!", "openHAB") ``` +::: + +::: tab JavaScript + +```javascript +var pushoverActions = actions.thingActions('pushover', 'pushover:pushover-account:account'); +// send HTML message +pushoverActions.sendHtmlMessage("Hello World!", "openHAB"); +``` + +::: + +:::: + +:::: tabs + +::: tab DSL + ```java val actions = getActions("pushover", "pushover:pushover-account:account") // send message with attachment @@ -103,6 +125,28 @@ actions.sendAttachmentMessage("Hello World!", "openHAB", "data:[][;b actions.sendAttachmentMessage("Hello World!", "openHAB", myImageItem.state.toFullString, null) ``` +::: + +::: tab JavaScript + +```javascript +var pushoverActions = actions.thingActions('pushover', 'pushover:pushover-account:account'); +// send message with attachment +pushoverActions.sendAttachmentMessage("Hello World!", "openHAB", "/path/to/my-local-image.png", "image/png"); +pushoverActions.sendAttachmentMessage("Hello World!", "openHAB", "https://www.openhab.org/openhab-logo-square.png", null); +pushoverActions.sendAttachmentMessage("Hello World!", "openHAB", "data:[][;base64],", null); +// in case you want to send the content of an Image Item (RawType) +pushoverActions.sendAttachmentMessage("Hello World!", "openHAB", items.myImageItem.rawState.toFullString(), null); +``` + +::: + +:::: + +:::: tabs + +::: tab DSL + ```java val actions = getActions("pushover", "pushover:pushover-account:account") // send priority message @@ -116,6 +160,27 @@ if( receipt !== null ) { } ``` +::: + +::: tab JavaScript + +```javascript +var pushoverActions = actions.thingActions('pushover', 'pushover:pushover-account:account'); +// send priority message +var receipt = pushoverActions.sendPriorityMessage("Emergency!!!", "openHAB", 2); + +// wait for your cancel condition + +if (receipt !== null ) { + pushoverActions.cancelPriorityMessage(receipt); + receipt = null; +} +``` + +::: + +:::: + :::: tabs ::: tab DSL