From 928ade1440209e726564a7d76334c4522c4c3a4e Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Thu, 4 Jul 2024 14:07:21 +0200 Subject: [PATCH] [jsscripting] Upgrade to openhab-js 5.3.1 (#16985) Depends on #16979. Signed-off-by: Florian Hotze --- .../README.md | 44 +++++++++++++------ .../pom.xml | 2 +- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/bundles/org.openhab.automation.jsscripting/README.md b/bundles/org.openhab.automation.jsscripting/README.md index 5bad40717dc17..688072d98f261 100644 --- a/bundles/org.openhab.automation.jsscripting/README.md +++ b/bundles/org.openhab.automation.jsscripting/README.md @@ -650,6 +650,15 @@ var response = actions.HTTP.sendHttpGetRequest(''); Replace `` 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. diff --git a/bundles/org.openhab.automation.jsscripting/pom.xml b/bundles/org.openhab.automation.jsscripting/pom.xml index 635b7fe079af7..91ef358e62b76 100644 --- a/bundles/org.openhab.automation.jsscripting/pom.xml +++ b/bundles/org.openhab.automation.jsscripting/pom.xml @@ -24,7 +24,7 @@ 22.0.0.2 ${project.version} - openhab@5.3.0 + openhab@5.3.1