mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-02-04 11:24:10 +01:00
Provide JavaScript examples (#17490)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
f7ab4f2307
commit
2ee86a07e9
@ -87,12 +87,34 @@ Thing pushover:pushover-account:account [ apikey="APP_TOKEN", user="USER_KEY" ]
|
|||||||
|
|
||||||
demo.rules:
|
demo.rules:
|
||||||
|
|
||||||
|
:::: tabs
|
||||||
|
|
||||||
|
::: tab DSL
|
||||||
|
|
||||||
```java
|
```java
|
||||||
val actions = getActions("pushover", "pushover:pushover-account:account")
|
val actions = getActions("pushover", "pushover:pushover-account:account")
|
||||||
// send HTML message
|
// send HTML message
|
||||||
actions.sendHtmlMessage("Hello <font color='green'>World</font>!", "openHAB")
|
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
|
```java
|
||||||
val actions = getActions("pushover", "pushover:pushover-account:account")
|
val actions = getActions("pushover", "pushover:pushover-account:account")
|
||||||
// send message with attachment
|
// 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)
|
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
|
```java
|
||||||
val actions = getActions("pushover", "pushover:pushover-account:account")
|
val actions = getActions("pushover", "pushover:pushover-account:account")
|
||||||
// send priority message
|
// 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
|
:::: tabs
|
||||||
|
|
||||||
::: tab DSL
|
::: tab DSL
|
||||||
|
Loading…
Reference in New Issue
Block a user