]> git.basschouten.com Git - openhab-addons.git/commitdiff
[openhabcloud] Update JRuby examples and minor changes to JS examples (#16997)
authorjimtng <2554958+jimtng@users.noreply.github.com>
Fri, 5 Jul 2024 08:52:40 +0000 (18:52 +1000)
committerGitHub <noreply@github.com>
Fri, 5 Jul 2024 08:52:40 +0000 (10:52 +0200)
* [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>
bundles/org.openhab.io.openhabcloud/README.md

index 40437d0b988e6d86ce941968e0f0cdc4af64c160..593dad69cf3e62a95afcfebd0f48ff4538c14e19 100644 (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
 ```