mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[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:
parent
f961c3329e
commit
7ae891e6d3
@ -212,12 +212,12 @@ rules.when().item('Apartment_FrontDoor').changed().to('OPEN').then(() => {
|
|||||||
rule "Front Door Notification" do
|
rule "Front Door Notification" do
|
||||||
changed Apartment_FrontDoor, to: OPEN
|
changed Apartment_FrontDoor, to: OPEN
|
||||||
run do
|
run do
|
||||||
notify("Front door was opened!", email: "me@email.com")
|
Notification.send("Front door was opened!", email: "me@email.com")
|
||||||
end
|
end
|
||||||
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
|
when
|
||||||
Item Apartment_Window changed to OPEN
|
Item Apartment_Window changed to OPEN
|
||||||
then
|
then
|
||||||
sendBroadcastNotification("Apartment window was opened!", "window", "HIGH")
|
sendBroadcastNotification("Apartment window was opened!", "window", "Door")
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ end
|
|||||||
rules.when().item('Apartment_Window').changed().to('OPEN').then(() => {
|
rules.when().item('Apartment_Window').changed().to('OPEN').then(() => {
|
||||||
actions.notificationBuilder('Apartment window was opened!')
|
actions.notificationBuilder('Apartment window was opened!')
|
||||||
.withIcon('window')
|
.withIcon('window')
|
||||||
.withSeverity('HIGH')
|
.withTag('Door')
|
||||||
.send();
|
.send();
|
||||||
}).build('Open Window Notification');
|
}).build('Open Window Notification');
|
||||||
```
|
```
|
||||||
@ -255,13 +255,13 @@ rules.when().item('Apartment_Window').changed().to('OPEN').then(() => {
|
|||||||
|
|
||||||
::: tab JRuby
|
::: 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
|
```ruby
|
||||||
rule "Open Window Notification" do
|
rule "Open Window Notification" do
|
||||||
changed Apartment_Window, to: OPEN
|
changed Apartment_Window, to: OPEN
|
||||||
run do
|
run do
|
||||||
notify("Apartment window was opened!", icon: "window", severity: "HIGH")
|
Notification.send("Apartment window was opened!", icon: "window", tag: "Door")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
@ -295,11 +295,11 @@ end
|
|||||||
rules.when().item('Apartment_MotionSensor').changed().to('ON').then(() => {
|
rules.when().item('Apartment_MotionSensor').changed().to('ON').then(() => {
|
||||||
actions.notificationBuilder('Motion detected in the apartment!')
|
actions.notificationBuilder('Motion detected in the apartment!')
|
||||||
.withIcon('motion')
|
.withIcon('motion')
|
||||||
.withTag('motion-tag')
|
.withTag('Motion Tag')
|
||||||
.withTitle('Motion Detected')
|
.withTitle('Motion Detected')
|
||||||
.withReferenceId('motion-id-1234')
|
.withReferenceId('motion-id-1234')
|
||||||
.withMediaAttachment('https://apartment.my/camera-snapshot.jpg')
|
.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();
|
.send();
|
||||||
}).build('Motion Detected Notification');
|
}).build('Motion Detected Notification');
|
||||||
```
|
```
|
||||||
@ -312,12 +312,13 @@ rules.when().item('Apartment_MotionSensor').changed().to('ON').then(() => {
|
|||||||
rule "Motion Detected Notification" do
|
rule "Motion Detected Notification" do
|
||||||
changed Apartment_MotionSensor, to: ON
|
changed Apartment_MotionSensor, to: ON
|
||||||
run do
|
run do
|
||||||
notify "Motion detected in the apartment!",
|
Notification.send "Motion detected in the apartment!",
|
||||||
icon: "motion",
|
icon: "motion",
|
||||||
tag: "motion-tag",
|
tag: "Motion Tag",
|
||||||
title: "Motion Detected",
|
title: "Motion Detected",
|
||||||
attachment: "https://apartment.my/camera-snapshot.jpg",
|
id: "motion-id-1234"
|
||||||
buttons: { "Turn on the light" => "command:Apartment_Light:ON" }
|
attachment: "https://apartment.my/camera-snapshot.jpg",
|
||||||
|
buttons: { "Turn on the light" => "command:Apartment_Light:ON" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user