Skip to content

Commit 2d41202

Browse files
authored
[jsscripting] Upgrade to openhab-js 5.3.1 (openhab#16985)
Depends on openhab#16979. Signed-off-by: Florian Hotze <[email protected]>
1 parent 2d7c9a2 commit 2d41202

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

bundles/org.openhab.automation.jsscripting/README.md

+30-14
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,15 @@ var response = actions.HTTP.sendHttpGetRequest('<url>');
650650

651651
Replace `<url>` with the request url.
652652

653+
#### Ping Actions
654+
655+
See [openhab-js : actions.Ping](https://openhab.github.io/openhab-js/actions.html#.Ping) for complete documentation.
656+
657+
```javascript
658+
// Check if a host is reachable
659+
var reachable = actions.Ping.checkVitality(host, port, timeout); // host: string, port: int, timeout: int
660+
```
661+
653662
#### ScriptExecution Actions
654663

655664
The `ScriptExecution` actions provide the `callScript(string scriptName)` method, which calls a script located at the `$OH_CONF/scripts` folder, as well as the `createTimer` method.
@@ -737,44 +746,51 @@ There are three different types of notifications:
737746
- Standard Notifications: Sent to the registered devices of the specified user and shown as notification on his devices.
738747
- Log Notifications: Only shown in the notification log, e.g. inside the Android and iOS Apps.
739748
749+
In addition to that, notifications can be updated later be re-using the same `referenceId` and hidden/removed either by `referenceId` or `tag`.
750+
740751
To send these three types of notifications, use the `notificationBuilder(message)` method of the `actions` namespace.
741752
It returns a new `NotificationBuilder` object, which by default sends a broadcast notification and provides the following methods:
742753
743754
- `.logOnly()`: Send a log notification only.
755+
- `.hide()`: Hides notifications with the specified `referenceId` or `tag`.
756+
- `.addUserId(emailAddress)`: By adding the email address(es) of specific openHAB Cloud user(s), the notification is only sent to this (these) user(s).
744757
- `.withIcon(icon)`: Sets the icon of the notification.
745-
- `.withSeverity(link)`: Sets the severity of the notification.
758+
- `.withTag(tag)`: Sets the tag of the notification. Used for grouping notifications and to hide/remove groups of notifications.
746759
- `.withTitle(title)`: Sets the title of the notification.
747-
- `.addUserId(emailAddress)`: By adding the email address(es) of specific openHAB Cloud user(s), the notification is only sent to this (these) user(s).
748-
- `.withOnClickAction(action)`: Sets the action to be performed when the notification is clicked.
760+
- `.withReferenceId(referenceId)`: Sets the reference ID of the notification. If none is set, but it might be useful, a random UUID will be generated.
761+
The reference ID can be used to update or hide the notification later by using the same reference ID again.
762+
- `.withOnClickAction(action)`: Sets the action to be executed when the notification is clicked.
749763
- `.withMediaAttachmentUrl(mediaAttachmentUrl)`: Sets the URL of a media attachment to be displayed with the notification. This URL must be reachable by the push notification client.
750-
- `.addActionButton(title, action)`: Adds an action button to the notification. Please note that due to Android and iOS limitations, only three action buttons are supported.
751-
- `.send()`: Sends the notification.
764+
- `.addActionButton(label, action)`: Adds an action button to the notification. Please note that due to Android and iOS limitations, only three action buttons are supported.
765+
- `.send()``string|null`: Sends the notification and returns the reference ID or `null` for log notifications and when hiding notifications.
766+
767+
The syntax for the `action` parameter is described in [openHAB Cloud Connector: Action Syntax](https://www.openhab.org/addons/integrations/openhabcloud/#action-syntax).
752768
753-
The syntax for the `action` parameter is described in [openHAB Cloud Connector: Action Syntax](https://www.openhab.org/addons/integrations/openhabcloud/#action-syntax).
769+
The syntax for the `mediaAttachmentUrl` parameter is described in [openHAB Cloud Connector](https://www.openhab.org/addons/integrations/openhabcloud/).
754770
755771
```javascript
756772
// Send a simple broadcast notification
757773
actions.notificationBuilder('Hello World!').send();
758-
// Send a broadcast notification with icon, severity and title
774+
// Send a broadcast notification with icon, tag and title
759775
actions.notificationBuilder('Hello World!')
760-
.withIcon('f7:bell_fill').withSeverity('important').withTitle('Important Notification').send();
761-
// Send a broadcast notification with icon, severity, title, media attachment URL and actions
776+
.withIcon('f7:bell_fill').withTag('important').withTitle('Important Notification').send();
777+
// Send a broadcast notification with icon, tag, title, media attachment URL and actions
762778
actions.notificationBuilder('Hello World!')
763-
.withIcon('f7:bell_fill').withSeverity('important').withTitle('Important Notification').
779+
.withIcon('f7:bell_fill').withTag('important').withTitle('Important Notification')
764780
.withOnClickAction('ui:navigate:/page/my_floorplan_page').withMediaAttachmentUrl('http://example.com/image.jpg')
765781
.addActionButton('Turn Kitchen Light ON=command:KitchenLights:ON').addActionButton('Turn Kitchen Light OFF=command:KitchenLights:OFF').send();
766782

767783
// Send a simple standard notification to two specific users
768784
actions.notificationBuilder('Hello World!').addUserId('[email protected]').addUserId('[email protected]').send();
769-
// Send a standard notification with icon, severity and title to two specific users
785+
// Send a standard notification with icon, tag and title to two specific users
770786
actions.notificationBuilder('Hello World!').addUserId('[email protected]').addUserId('[email protected]')
771-
.withIcon('f7:bell_fill').withSeverity('important').withTitle('Important notification').send();
787+
.withIcon('f7:bell_fill').withTag('important').withTitle('Important notification').send();
772788

773789
// Sends a simple log notification
774790
actions.notificationBuilder('Hello World!').logOnly().send();
775-
// Sends a simple log notification with icon and severity
791+
// Sends a simple log notification with icon and tag
776792
actions.notificationBuilder('Hello World!').logOnly()
777-
.withIcon('f7:bell_fill').withSeverity('important').send();
793+
.withIcon('f7:bell_fill').withTag('important').send();
778794
```
779795
780796
See [openhab-js : actions.NotificationBuilder](https://openhab.github.io/openhab-js/actions.html#.notificationBuilder) for complete documentation.

bundles/org.openhab.automation.jsscripting/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</bnd.importpackage>
2525
<graal.version>22.0.0.2</graal.version> <!-- DO NOT UPGRADE: 22.0.0.2 is the latest version working on armv7l / OpenJDK 11.0.16 & armv7l / Zulu 17.0.5+8 -->
2626
<oh.version>${project.version}</oh.version>
27-
<ohjs.version>[email protected].0</ohjs.version>
27+
<ohjs.version>[email protected].1</ohjs.version>
2828
</properties>
2929

3030
<build>

0 commit comments

Comments
 (0)