From 375cd8687f8c26a68ffa9c60f677cf79434275eb Mon Sep 17 00:00:00 2001 From: Scott Rushworth Date: Mon, 16 Dec 2019 23:34:18 -0500 Subject: [PATCH 1/2] Added missing preset variables Signed-off-by: Scott Rushworth --- configuration/jsr223.md | 88 ++++++++++++++++++++++++++--------------- 1 file changed, 56 insertions(+), 32 deletions(-) diff --git a/configuration/jsr223.md b/configuration/jsr223.md index 7f1f849399..d8bf0ab6c5 100644 --- a/configuration/jsr223.md +++ b/configuration/jsr223.md @@ -145,7 +145,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) @@ -158,58 +158,83 @@ The Default preset is preloaded, so it does not require importing. | 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 | +| | | | `OnOffType` | `org.eclipse.smarthome.core.library.types.OnOffType` | | `ON` | `OnOffType` enum item | | `OFF` | `OnOffType` enum item | +| | | | `OpenClosedType` | `org.eclipse.smarthome.core.library.types.OpenClosedType` | | `OPEN` | `OpenClosedType` enum item | | `CLOSED` | `OpenClosedType` enum item | +| | | | `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` | +| | | +| `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>` | -| `itemRegistry` | Instance of `org.eclipse.smarthome.core.items.ItemRegistry` | | `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] | @@ -230,7 +255,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") @@ -241,21 +266,21 @@ 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 | | 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 | #### `RuleSupport` Preset -These variables are loaded using: +These variables and classes are loaded using: ```python scriptExtension.importPreset("RuleSupport") @@ -263,12 +288,17 @@ 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` | +| ActionBuilder | `org.openhab.core.automation.ActionBuilder` | | Condition | `org.openhab.core.automation.Condition` | -| Trigger | `org.openhab.core.automation.Trigger` | +| 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` | +| 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` | @@ -285,12 +315,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 | - From 7c2039e16bd41854c3a6dc22b769cbeece197408 Mon Sep 17 00:00:00 2001 From: Scott Rushworth Date: Thu, 20 Feb 2020 15:38:09 -0500 Subject: [PATCH 2/2] Cleaned up blank lines, fixed table, and added file name for SimpleRule Signed-off-by: Scott Rushworth --- configuration/jsr223.md | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/configuration/jsr223.md b/configuration/jsr223.md index d8bf0ab6c5..40abce22cb 100644 --- a/configuration/jsr223.md +++ b/configuration/jsr223.md @@ -157,58 +157,45 @@ The `default` preset is preloaded, so it does not require importing. #### Default Preset (`importPreset` not required) | Variable | Description | -|---------|-------------| +|----------|-------------| | `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` | -| | | | `IncreaseDecreaseType` | `org.eclipse.smarthome.core.library.types.IncreaseDecreaseType` | | `DECREASE` | `IncreaseDecreaseType` enum item | | `INCREASE` | `IncreaseDecreaseType` enum item | -| | | | `OnOffType` | `org.eclipse.smarthome.core.library.types.OnOffType` | | `ON` | `OnOffType` enum item | | `OFF` | `OnOffType` enum item | -| | | | `OpenClosedType` | `org.eclipse.smarthome.core.library.types.OpenClosedType` | | `OPEN` | `OpenClosedType` enum item | | `CLOSED` | `OpenClosedType` enum item | -| | | | `StopMoveType` | `org.eclipse.smarthome.core.library.types.StopMoveType` | | `STOP` | `StopMoveType` enum item | | `MOVE` | `StopMoveType` 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 | -| | | | `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` | @@ -218,13 +205,11 @@ The `default` preset is preloaded, so it does not require importing. | `PercentType` | `org.eclipse.smarthome.core.library.types.PercentType` | | `PointType` | `org.eclipse.smarthome.core.library.types.PointType` | | `StringType` | `org.eclipse.smarthome.core.library.types.StringType` | -| | | | `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` | @@ -232,7 +217,6 @@ The `default` preset is preloaded, so it does not require importing. | `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` | @@ -265,13 +249,13 @@ The primary usage of this preset is for defining rule (`SimpleRule`) subclasses. See language-specific documentation for examples. | Variable | Description | -|----------|------|-------| +|----------|-------------| | 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 | +| 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` | | Visibility | `org.openhab.core.automation.Visibility` enum |