Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing preset variables #1104

Merged
merged 3 commits into from
Feb 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 45 additions & 37 deletions configuration/jsr223.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ For example, with the following scripts and directory structure...

To faciliate JSR223 scripting, several openHAB-related variables are automatically predefined within `ScriptExtension` presets.
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.
The `default` preset is preloaded, so it does not require importing.

- [`Default`](#default_presets)
- [`RuleSimple`](#rulesimple_presets)
Expand All @@ -159,19 +159,16 @@ The Default preset is preloaded, so it does not require importing.
#### Default Preset (`importPreset` not required)

| Variable | Description |
|---------|-------------|
| `State` | `org.eclipse.smarthome.core.types.State` |
| `Command` | `org.eclipse.smarthome.core.types.State` |
|----------|-------------|
| `DateTime` | `org.joda.time.DateTime` (if Jodatime is available) |
| `LocalTime` | `org.joda.time.LocalTime` (if Jodatime is available) |
| `State` | `org.eclipse.smarthome.core.types.State` |
| `Command` | `org.eclipse.smarthome.core.types.State` |
| `StringUtils` | `org.apache.commons.lang.StringUtils` |
| `URLEncoder` | `java.net.URLEncoder` |
| `FileUtils` | `org.apache.commons.io.FileUtils` |
| `FilenameUtils` | `org.apache.commons.io.FilenameUtils` |
| `File` | `java.io.File` |
| `UnDefType` | `org.eclipse.smarthome.core.library.types.UnDefType` |
| `NULL` | `UnDefType` enum item |
| `UNDEF` | `UnDefType` enum item |
| `IncreaseDecreaseType` | `org.eclipse.smarthome.core.library.types.IncreaseDecreaseType` |
| `DECREASE` | `IncreaseDecreaseType` enum item |
| `INCREASE` | `IncreaseDecreaseType` enum item |
Expand All @@ -184,34 +181,46 @@ The Default preset is preloaded, so it does not require importing.
| `StopMoveType` | `org.eclipse.smarthome.core.library.types.StopMoveType` |
| `STOP` | `StopMoveType` enum item |
| `MOVE` | `StopMoveType` enum item |
| `RewindFastforwardType` | `org.eclipse.smarthome.core.library.types.RewindFastforwardType` |
| `REWIND` | `RewindFastforwardType` enum item |
| `FASTFORWARD` | `RewindFastforwardType` enum item |
| `UpDownType` | `org.eclipse.smarthome.core.library.types.UpDownType` |
| `UP` | `UpDownType` enum item |
| `DOWN` | `UpDownType` enum item |
| `UnDefType` | `org.eclipse.smarthome.core.library.types.UnDefType` |
| `NULL` | `UnDefType` enum item |
| `UNDEF` | `UnDefType` enum item |
| `RefreshType` | `org.eclipse.smarthome.core.library.types.RefreshType` |
| `REFRESH` | `RefreshType` enum item |
| `NextPreviousType` | `org.eclipse.smarthome.core.library.types.NextPreviusType` |
| `NEXT` | `NextPreviousType` enum item |
| `PREVIOUS` | `NextPreviousType` enum item |
| `PlayPauseType` | `org.eclipse.smarthome.core.library.types.PlayPauseType` |
| `PLAY` | `PlayPauseType` enum item |
| `PAUSE` | `PlayPauseType` enum item |
| `UpDownType` | `org.eclipse.smarthome.core.library.types.UpDownType` |
| `UP` | `UpDownType` enum item |
| `DOWN` | `UpDownType` enum item |
| `DecimalType` | `org.eclipse.smarthome.core.library.types.DecimalType` |
| `RewindFastforwardType` | `org.eclipse.smarthome.core.library.types.RewindFastforwardType` |
| `REWIND` | `RewindFastforwardType` enum item |
| `FASTFORWARD` | `RewindFastforwardType` enum item |
| `QuantityType` | `org.eclipse.smarthome.core.library.types.QuantityType` |
| `StringListType` | `org.eclipse.smarthome.core.library.types.StringListType` |
| `RawType` | `org.eclipse.smarthome.core.library.types.RawType` |
| `DateTimeType` | `org.eclipse.smarthome.core.library.types.DateTimeType` |
| `DecimalType` | `org.eclipse.smarthome.core.library.types.DecimalType` |
| `HSBType` | `org.eclipse.smarthome.core.library.types.HSBType` |
| `PercentType` | `org.eclipse.smarthome.core.library.types.PercentType` |
| `PointType` | `org.eclipse.smarthome.core.library.types.PointType` |
| `StringType` | `org.eclipse.smarthome.core.library.types.StringType` |
| `StringListType` | `org.eclipse.smarthome.core.library.types.StringListType` |
| `RawType` | `org.eclipse.smarthome.core.library.types.RawType` |
| `items` | Instance of `java.util.Map<String, State>` |
| `itemRegistry` | Instance of `org.eclipse.smarthome.core.items.ItemRegistry` |
| `SIUnits` | `org.eclipse.smarthome.core.library.unit.SIUnits` |
| `ImperialUnits` | `org.eclipse.smarthome.core.library.unit.SmartHomeUnits` |
| `MetricPrefix` | `org.eclipse.smarthome.core.library.unit.SmartHomeUnits` |
| `SmartHomeUnits` | `org.eclipse.smarthome.core.library.unit.SmartHomeUnits` |
| `BinaryPrefix` | `org.eclipse.smarthome.core.library.unit.SmartHomeUnits` |
| `items` | Instance of `java.util.Map<String, State>` |
| `ir` | Alias for `itemRegistry` |
| `itemRegistry` | Instance of `org.eclipse.smarthome.core.items.ItemRegistry` |
| `things` | Instance of `org.eclipse.smarthome.core.thing.ThingRegistry` |
| `rules` | Instance of `org.openhab.core.automation.RuleRegistry` |
| `events` | (internal) Used to send events, post commands, etc. [Details](#event_operations) below] |
| `actions` | Instance of `org.eclipse.smarthome.core.thing.binding.ThingActions` |
| `scriptExtension` | (internal) For loading script presets. |
| `se` | Alias for `scriptExtension` |
| `events` | (internal) Used to send events, post commands, etc. [Details](#event_operations) below] |

<a name="#event_operations"></a>

Expand All @@ -232,7 +241,7 @@ The Default preset is preloaded, so it does not require importing.

#### RuleSimple Preset

These variables are loaded using:
These variables and classes are loaded using:

```python
scriptExtension.importPreset("RuleSimple")
Expand All @@ -242,35 +251,40 @@ The primary usage of this preset is for defining rule (`SimpleRule`) subclasses.
See language-specific documentation for examples.

| Variable | Description |
|----------|------|-------|
| SimpleRule | Base class for Jython Rules |
|----------|-------------|
| ActionType | `org.openhab.core.automation.type.ActionType` |
| ConfigDescriptionParameter | `org.eclipse.smarthome.config.core.ConfigDescriptionParameter` |
| ModuleType | `org.openhab.core.automation.type.ModuleType` |
| SimpleActionHandler | `org.openhab.core.automation.module.script.rulesupport.shared.simple.SimpleActionHandler` |
| SimpleConditionHandler | `org.openhab.core.automation.module.script.rulesupport.shared.simple.SimpleConditionHandler` |
| SimpleRule | Base class for Jython Rules `org.openhab.core.automation.module.script.rulesupport.shared.simple.SimpleRule` |
| SimpleTriggerHandler | `org.openhab.core.automation.module.script.rulesupport.shared.simple.SimpleTriggerHandler` |
| TriggerType | `org.openhab.core.automation.type.TriggerType` |
| ConfigDescriptionParameter | `org.eclipse.smarthome.config.core.ConfigDescriptionParameter` |
| ModuleType | `org.openhab.core.automation.type.ModuleType` |
| ActionType | `org.openhab.core.automation.type.ActionType` |
| Visibility | `org.openhab.core.automation.Visibility` enum |

<a name="rulesupport_presets"></a>

#### `RuleSupport` Preset

These variables are loaded using:
These variables and classes are loaded using:

```python
scriptExtension.importPreset("RuleSupport")
```

| Variable | Description |
|----------|-------------|
| automationManager | Instance for managing rules and other openHAB module instances. (e.g., `addRule`) |
| Configuration | `org.eclipse.smarthome.config.core.Configuration` |
| Action | `org.openhab.core.automation.Action` |
| Condition | `org.openhab.core.automation.Condition` |
| Action | `org.openhab.core.automation.Action` |
| ActionBuilder | `org.openhab.core.automation.ActionBuilder` |
| Condition | `org.openhab.core.automation.Condition` |
| ConditionBuilder | `org.openhab.core.automation.ConditionBuilder` |
| Configuration | `org.eclipse.smarthome.config.core.Configuration` |
| ModuleBuilder | `org.openhab.core.automation.ModuleBuilder` |
| Rule | `org.openhab.core.automation.Rule` (use `SimpleRule` for defining rules) |
| Trigger | `org.openhab.core.automation.Trigger` |
| Rule | `org.openhab.core.automation.Rule` (use `SimpleRule` for defining rules) |
| TriggerBuilder | `org.openhab.core.automation.TriggerBuilder` |
| automationManager | Instance for managing rules and other openHAB module instances. (e.g., `addRule`) |
| ruleRegistry | `org.openhab.core.automation.Rule` |

<a name="rulefactories_presets"></a>

Expand All @@ -287,12 +301,6 @@ scriptExtension.importPreset("RuleFactories")
| `ActionHandlerFactory` | `org.openhab.core.automation.module.script.rulesupport.shared.factories.ScriptedActionHandlerFactory` |
| `ConditionHandlerFactory` | `org.openhab.core.automation.module.script.rulesupport.shared.factories.ScriptedConditionHandlerFactory` |
| `TriggerHandlerFactory` | `org.openhab.core.automation.module.script.rulesupport.shared.factories.ScriptedTriggerHandlerFactory` |
| `TriggerType` | `org.openhab.core.automation.type.TriggerType` |
| `ConfigDescriptionParameter` | `org.eclipse.smarthome.config.core.ConfigDescriptionParameter` |
| `ModuleType` | `org.openhab.core.automation.type.ModuleType` |
| `ActionType` | `org.openhab.core.automation.type.ActionType` |
| `Visibility` | `org.openhab.core.automation.Visibility` enum |


<a name="trigger_types"></a>

Expand Down