]> git.basschouten.com Git - openhab-addons.git/commitdiff
Provide JavaScript examples (#17490)
authorJacob Laursen <jacob-github@vindvejr.dk>
Tue, 1 Oct 2024 12:12:22 +0000 (14:12 +0200)
committerGitHub <noreply@github.com>
Tue, 1 Oct 2024 12:12:22 +0000 (14:12 +0200)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
bundles/org.openhab.binding.pushover/README.md

index 712f9173fa1ca73e9eabf409fbd3ed5223b1b14c..afcbd476fc27bc429aa9091de4f223e6c1f0d969 100644 (file)
@@ -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 <font color='green'>World</font>!", "openHAB")
 ```
 
+:::
+
+::: tab JavaScript
+
+```javascript
+var pushoverActions = actions.thingActions('pushover', 'pushover:pushover-account:account');
+// send HTML message
+pushoverActions.sendHtmlMessage("Hello <font color='green'>World</font>!", "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:[<media type>][;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:[<media type>][;base64],<data>", 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