]> git.basschouten.com Git - openhab-addons.git/commitdiff
[jsscripting] Upgrade to openhab-js 5.3.1 (#16985)
authorFlorian Hotze <florianh_dev@icloud.com>
Thu, 4 Jul 2024 12:07:21 +0000 (14:07 +0200)
committerGitHub <noreply@github.com>
Thu, 4 Jul 2024 12:07:21 +0000 (14:07 +0200)
Depends on #16979.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
bundles/org.openhab.automation.jsscripting/README.md
bundles/org.openhab.automation.jsscripting/pom.xml

index 5bad40717dc17092d2559b855d802672852e2eb6..688072d98f261a6ba5186c188ecede6b97415ff9 100644 (file)
@@ -650,6 +650,15 @@ var response = actions.HTTP.sendHttpGetRequest('<url>');
 
 Replace `<url>` with the request url.
 
+#### Ping Actions
+
+See [openhab-js : actions.Ping](https://openhab.github.io/openhab-js/actions.html#.Ping) for complete documentation.
+
+```javascript
+// Check if a host is reachable
+var reachable = actions.Ping.checkVitality(host, port, timeout); // host: string, port: int, timeout: int
+```
+
 #### ScriptExecution Actions
 
 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:
 - Standard Notifications: Sent to the registered devices of the specified user and shown as notification on his devices.
 - Log Notifications: Only shown in the notification log, e.g. inside the Android and iOS Apps.
 
+In addition to that, notifications can be updated later be re-using the same `referenceId` and hidden/removed either by `referenceId` or `tag`.
+
 To send these three types of notifications, use the `notificationBuilder(message)` method of the `actions` namespace.
 It returns a new `NotificationBuilder` object, which by default sends a broadcast notification and provides the following methods:
 
 - `.logOnly()`: Send a log notification only.
+- `.hide()`: Hides notifications with the specified `referenceId` or `tag`.
+- `.addUserId(emailAddress)`: By adding the email address(es) of specific openHAB Cloud user(s), the notification is only sent to this (these) user(s).
 - `.withIcon(icon)`: Sets the icon of the notification.
-- `.withSeverity(link)`: Sets the severity of the notification.
+- `.withTag(tag)`: Sets the tag of the notification. Used for grouping notifications and to hide/remove groups of notifications.
 - `.withTitle(title)`: Sets the title of the notification.
-- `.addUserId(emailAddress)`: By adding the email address(es) of specific openHAB Cloud user(s), the notification is only sent to this (these) user(s).
-- `.withOnClickAction(action)`: Sets the action to be performed when the notification is clicked.
+- `.withReferenceId(referenceId)`: Sets the reference ID of the notification. If none is set, but it might be useful, a random UUID will be generated.
+  The reference ID can be used to update or hide the notification later by using the same reference ID again.
+- `.withOnClickAction(action)`: Sets the action to be executed when the notification is clicked.
 - `.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.
-- `.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.
-- `.send()`: Sends the notification.
+- `.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.
+- `.send()` ⇒ `string|null`: Sends the notification and returns the reference ID or `null` for log notifications and when hiding notifications.
+
+The syntax for the `action` parameter is described in [openHAB Cloud Connector: Action Syntax](https://www.openhab.org/addons/integrations/openhabcloud/#action-syntax).
 
-The syntax for the `action` parameter is  described in [openHAB Cloud Connector: Action Syntax](https://www.openhab.org/addons/integrations/openhabcloud/#action-syntax).
+The syntax for the `mediaAttachmentUrl` parameter is described in [openHAB Cloud Connector](https://www.openhab.org/addons/integrations/openhabcloud/).
 
 ```javascript
 // Send a simple broadcast notification
 actions.notificationBuilder('Hello World!').send();
-// Send a broadcast notification with icon, severity and title
+// Send a broadcast notification with icon, tag and title
 actions.notificationBuilder('Hello World!')
-  .withIcon('f7:bell_fill').withSeverity('important').withTitle('Important Notification').send();
-// Send a broadcast notification with icon, severity, title, media attachment URL and actions
+  .withIcon('f7:bell_fill').withTag('important').withTitle('Important Notification').send();
+// Send a broadcast notification with icon, tag, title, media attachment URL and actions
 actions.notificationBuilder('Hello World!')
-  .withIcon('f7:bell_fill').withSeverity('important').withTitle('Important Notification').
+  .withIcon('f7:bell_fill').withTag('important').withTitle('Important Notification')
   .withOnClickAction('ui:navigate:/page/my_floorplan_page').withMediaAttachmentUrl('http://example.com/image.jpg')
   .addActionButton('Turn Kitchen Light ON=command:KitchenLights:ON').addActionButton('Turn Kitchen Light OFF=command:KitchenLights:OFF').send();
 
 // Send a simple standard notification to two specific users
 actions.notificationBuilder('Hello World!').addUserId('florian@example.com').addUserId('florian@example.org').send();
-// Send a standard notification with icon, severity and title to two specific users
+// Send a standard notification with icon, tag and title to two specific users
 actions.notificationBuilder('Hello World!').addUserId('florian@example.com').addUserId('florian@example.org')
-  .withIcon('f7:bell_fill').withSeverity('important').withTitle('Important notification').send();
+  .withIcon('f7:bell_fill').withTag('important').withTitle('Important notification').send();
 
 // Sends a simple log notification
 actions.notificationBuilder('Hello World!').logOnly().send();
-// Sends a simple log notification with icon and severity
+// Sends a simple log notification with icon and tag
 actions.notificationBuilder('Hello World!').logOnly()
-  .withIcon('f7:bell_fill').withSeverity('important').send();
+  .withIcon('f7:bell_fill').withTag('important').send();
 ```
 
 See [openhab-js : actions.NotificationBuilder](https://openhab.github.io/openhab-js/actions.html#.notificationBuilder) for complete documentation.
index 635b7fe079af78fdc0ddc6cc3e8e4948cba916b4..91ef358e62b76f39e0911a7f9f6568ea22db028e 100644 (file)
@@ -24,7 +24,7 @@
     </bnd.importpackage>
     <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 -->
     <oh.version>${project.version}</oh.version>
-    <ohjs.version>openhab@5.3.0</ohjs.version>
+    <ohjs.version>openhab@5.3.1</ohjs.version>
   </properties>
 
   <build>