[openhabcloud] Update JRuby examples and minor changes to JS examples (#16997)

* [openhabcloud] Update JRuby examples and minor changes to JS examples
* remove table delimiter row padding, change tag HIGH to Door
* js addActionButton('Turn on the light', 'command:Apartment_Light:ON')

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
jimtng 2024-07-05 18:52:40 +10:00 committed by GitHub
parent f961c3329e
commit 7ae891e6d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -212,12 +212,12 @@ rules.when().item('Apartment_FrontDoor').changed().to('OPEN').then(() => {
rule "Front Door Notification" do
changed Apartment_FrontDoor, to: OPEN
run do
notify("Front door was opened!", email: "me@email.com")
Notification.send("Front door was opened!", email: "me@email.com")
end
end
```
See [notify](https://openhab.github.io/openhab-jruby/main/OpenHAB/Core/Actions.html#notify-class_method)
See [Notification.send](https://openhab.github.io/openhab-jruby/main/OpenHAB/Core/Actions/Notification.html#send-class_method)
:::
@ -234,7 +234,7 @@ rule "Open Window Notification"
when
Item Apartment_Window changed to OPEN
then
sendBroadcastNotification("Apartment window was opened!", "window", "HIGH")
sendBroadcastNotification("Apartment window was opened!", "window", "Door")
end
```
@ -246,7 +246,7 @@ end
rules.when().item('Apartment_Window').changed().to('OPEN').then(() => {
actions.notificationBuilder('Apartment window was opened!')
.withIcon('window')
.withSeverity('HIGH')
.withTag('Door')
.send();
}).build('Open Window Notification');
```
@ -255,13 +255,13 @@ rules.when().item('Apartment_Window').changed().to('OPEN').then(() => {
::: tab JRuby
Broadcast notification is performed by calling [notify](https://openhab.github.io/openhab-jruby/main/OpenHAB/Core/Actions.html#notify-class_method) without providing an email address.
Broadcast notification is performed by calling [Notification.send](https://openhab.github.io/openhab-jruby/main/OpenHAB/Core/Actions/Notification.html#send-class_method) without providing an email address.
```ruby
rule "Open Window Notification" do
changed Apartment_Window, to: OPEN
run do
notify("Apartment window was opened!", icon: "window", severity: "HIGH")
Notification.send("Apartment window was opened!", icon: "window", tag: "Door")
end
end
```
@ -295,11 +295,11 @@ end
rules.when().item('Apartment_MotionSensor').changed().to('ON').then(() => {
actions.notificationBuilder('Motion detected in the apartment!')
.withIcon('motion')
.withTag('motion-tag')
.withTag('Motion Tag')
.withTitle('Motion Detected')
.withReferenceId('motion-id-1234')
.withMediaAttachment('https://apartment.my/camera-snapshot.jpg')
.addActionButton('Turn on the light=command:Apartment_Light:ON')
.addActionButton('Turn on the light', 'command:Apartment_Light:ON')
.send();
}).build('Motion Detected Notification');
```
@ -312,12 +312,13 @@ rules.when().item('Apartment_MotionSensor').changed().to('ON').then(() => {
rule "Motion Detected Notification" do
changed Apartment_MotionSensor, to: ON
run do
notify "Motion detected in the apartment!",
icon: "motion",
tag: "motion-tag",
title: "Motion Detected",
attachment: "https://apartment.my/camera-snapshot.jpg",
buttons: { "Turn on the light" => "command:Apartment_Light:ON" }
Notification.send "Motion detected in the apartment!",
icon: "motion",
tag: "Motion Tag",
title: "Motion Detected",
id: "motion-id-1234"
attachment: "https://apartment.my/camera-snapshot.jpg",
buttons: { "Turn on the light" => "command:Apartment_Light:ON" }
end
end
```