Skip to content

Commit

Permalink
Provide JavaScript examples (openhab#17490)
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Laursen <[email protected]>
  • Loading branch information
jlaur authored Oct 1, 2024
1 parent b11c751 commit 2535c6a
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions bundles/org.openhab.binding.pushover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2535c6a

Please sign in to comment.