Rules tweaks (#2336)

* Update JRuby notification action

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>

* split helper library code into separate blocks for clarity

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>

---------

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
pull/2337/head
jimtng 2024-07-17 04:56:46 +10:00 committed by GitHub
parent 550ea8608c
commit 9f48d8153a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 7 deletions

View File

@ -625,7 +625,7 @@ rule "Window open reminder" do
changed gWindows.members, to: OPEN, for: 1.hour
run do |event|
# Item guaranteed to be OPEN here, no need to check
notify("#{event.item.label} is open for an hour!")
Notification.send("#{event.item.label} is open for an hour!")
end
end
```

View File

@ -89,7 +89,9 @@ sRule.setTriggers([
]);
automationManager.addRule(sRule);
```
```js
// And the same rule using the helper library:
const { rules, triggers } = require('openhab');
@ -185,7 +187,9 @@ s_rule.set_triggers([
])
$automationManager.add_rule(s_rule)
```
```ruby
# And the same rule using the bundled helper library:
rule "A Cron Rule in Ruby" do
@ -234,12 +238,18 @@ To facilitate JSR223 scripting, several openHAB-related variables are automatica
They can be loaded into the script context using `scriptExtension.importPreset(String preset)`, e.g. `scriptExtension.importPreset("RuleSimple")`.
The `default` preset is preloaded, so it does not require importing.
- [`Default`](#default-preset-importpreset-not-required)
- [`RuleSimple`](#rulesimple-preset)
- [`RuleSupport`](#rulesupport-preset)
- [`RuleFactories`](#rulefactories-preset)
- [`ScriptAction`](#scriptaction-preset)
- [`cache`](#cache-preset)
- [Overview](#overview)
- [Example rules for a first impression](#example-rules-for-a-first-impression)
- [Script Locations](#script-locations)
- [`ScriptExtension` Objects (all JSR223 languages)](#scriptextension-objects-all-jsr223-languages)
- [Default Preset (`importPreset` not required)](#default-preset-importpreset-not-required)
- [`events` operations](#events-operations)
- [RuleSimple Preset](#rulesimple-preset)
- [`RuleSupport` Preset](#rulesupport-preset)
- [`RuleFactories` Preset](#rulefactories-preset)
- [`ScriptAction` Preset](#scriptaction-preset)
- [`cache` Preset](#cache-preset)
- [`TriggerType` Objects (all JSR223 languages)](#triggertype-objects-all-jsr223-languages)
#### Default Preset (`importPreset` not required)