Skip to content

Commit

Permalink
Merge commit '661c450fa7295ba8a7f66c7be355c6a80effd25f' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
openHAB Build Server committed Dec 16, 2019
2 parents 7e312cb + 661c450 commit ae6ae72
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
2 changes: 1 addition & 1 deletion addons/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Note: The commandLine variable often has to use a special format where @@ needs

- `sendHttpGetRequest(String url)`: Sends an GET-HTTP request and returns the result as a String
- `sendHttpPutRequest(String url)`: Sends a PUT-HTTP request and returns the result as a String
- `sendHttpPutRequest(String url, Sting contentType, String content)`: Sends a PUT-HTTP request with the given content and returns the result as a String
- `sendHttpPutRequest(String url, String contentType, String content)`: Sends a PUT-HTTP request with the given content and returns the result as a String
- `sendHttpPostRequest(String url)`: Sends a POST-HTTP request and returns the result as a String
- `sendHttpPostRequest(String url, String contentType, String content)`: Sends a POST-HTTP request with the given content and returns the result as a String
- `sendHttpDeleteRequest(String url)`: Sends a DELETE-HTTP request and returns the result as a String
Expand Down
10 changes: 5 additions & 5 deletions configuration/jsr223-jython.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ To enable debug logging, use the [Karaf logging]({{base}}/administration/logging
enable debug logging for the automation functionality:

```text
log:set DEBUG org.eclipse.smarthome.automation
log:set DEBUG org.openhab.core.automation
```

## Script Examples
Expand All @@ -72,15 +72,15 @@ The openHAB server uses the [SLFJ](https://www.slf4j.org/) library for logging.
```python
from org.slf4j import LoggerFactory

LoggerFactory.getLogger("org.eclipse.smarthome.automation.examples").info("Hello world!")
LoggerFactory.getLogger("org.openhab.core.automation.examples").info("Hello world!")
```

Jython can [import Java classes](http://www.jython.org/jythonbook/en/1.0/ModulesPackages.html).
Depending on the openHAB logging configuration,
you may need to prefix logger names with `org.eclipse.smarthome.automation`
you may need to prefix logger names with `org.openhab.core.automation`
for them to show up in the log file (or you modify the logging configuration).

> NOTE: Be careful with using wildcards when importing Java packages (e.g., `import org.sl4j.*`).
> NOTE: Be careful with using wildcards when importing Java packages (e.g., `import org.sl4j.*`).
> This will work in some cases, but it might not work in some situations.
> It's best to use explicit imports with Java packages.
> For more details, see the Jython documentation on
Expand All @@ -90,7 +90,7 @@ The script then uses the [LoggerFactory](https://www.slf4j.org/apidocs/org/slf4j
to obtain a named logger and then logs a message like:

```text
... [INFO ] [.smarthome.automation.examples:-2 ] - Hello world!
... [INFO ] [.openhab.core.automation.examples:-2 ] - Hello world!
```

Notice that no rules were required for this simple script.
Expand Down
32 changes: 16 additions & 16 deletions configuration/jsr223.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ title: JSR223 Scripting
## Overview

[JSR223](https://docs.oracle.com/javase/6/docs/technotes/guides/scripting/) ([spec](https://jcp.org/aboutJava/communityprocess/pr/jsr223/index.html)) is a standard scripting API for Java Virtual Machine (JVM) [languages](https://en.wikipedia.org/wiki/List_of_JVM_languages).
[JSR223](https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/) ([spec](https://jcp.org/aboutJava/communityprocess/pr/jsr223/index.html)) is a standard scripting API for Java Virtual Machine (JVM) [languages](https://en.wikipedia.org/wiki/List_of_JVM_languages).
The JVM languages provide varying levels of support for the JSR223 API and interoperability with the Java runtime.
Currently the following languages are known to work well for openHAB scripting:
[**Jython**](https://jython.github.io/) (Python on the JVM),
Expand Down Expand Up @@ -89,8 +89,8 @@ automationManager.addRule(sRule)

::: tab Groovy
```groovy
import org.eclipse.smarthome.automation.*
import org.eclipse.smarthome.automation.module.script.rulesupport.shared.simple.*
import org.openhab.core.automation.*
import org.openhab.core.automation.module.script.rulesupport.shared.simple.*
import org.eclipse.smarthome.config.core.Configuration
scriptExtension.importPreset("RuleSupport")
Expand All @@ -117,12 +117,12 @@ automationManager.addRule(sRule)

### Script Locations

Scripts should be placed in the `${OPENHAB_CONF}/automation/jsr223/` directory.
Scripts should be placed in the `${OPENHAB_CONF}/automation/jsr223/` directory.
This directory will vary, [based on the type of openHAB installation used](https://www.openhab.org/docs/installation/linux.html#installation).
For example, Linux installations created with a package installer will use `/etc/openhab2/automation/jsr223/`, and manual installations will use `/opt/openhab2/conf/automation/jsr223/`.

When openHAB starts, scripts will be loaded in an order based on their file name.
If the scripts have the same name, which should rarely happen, the parent directories will be considered in the sort.
When openHAB starts, scripts will be loaded in an order based on their file name.
If the scripts have the same name, which should rarely happen, the parent directories will be considered in the sort.
For example, with the following scripts and directory structure...

```text
Expand All @@ -144,7 +144,7 @@ For example, with the following scripts and directory structure...
### `ScriptExtension` Objects (all JSR223 languages)

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")`.
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_presets)
Expand Down Expand Up @@ -206,7 +206,7 @@ The Default preset is preloaded, so it does not require importing.
| `itemRegistry` | Instance of `org.eclipse.smarthome.core.items.ItemRegistry` |
| `ir` | Alias for `itemRegistry` |
| `things` | Instance of `org.eclipse.smarthome.core.thing.ThingRegistry` |
| `rules` | Instance of `org.eclipse.smarthome.automation.RuleRegistry` |
| `rules` | Instance of `org.openhab.core.automation.RuleRegistry` |
| `scriptExtension` | (internal) For loading script presets. |
| `se` | Alias for `scriptExtension` |
| `events` | (internal) Used to send events, post commands, etc. [Details](#event_operations) below] |
Expand Down Expand Up @@ -236,7 +236,7 @@ These variables are loaded using:
scriptExtension.importPreset("RuleSimple")
```

The primary usage of this preset is for defining rule (`SimpleRule`) subclasses.
The primary usage of this preset is for defining rule (`SimpleRule`) subclasses.
See language-specific documentation for examples.

| Variable | Description |
Expand Down Expand Up @@ -282,14 +282,14 @@ scriptExtension.importPreset("RuleFactories")

| Variable | Description |
|----------|-------------|
| `ActionHandlerFactory` | `org.openhab.core.automation.module.script.rulesupport.shared.factories.ActionHandlerFactory` |
| `ConditionHandlerFactory` | `org.openhab.core.automation.module.script.rulesupport.shared.factories.ConditionHandlerFactory` |
| `TriggerHandlerFactory` | `org.openhab.core.automation.module.script.rulesupport.shared.factories.TriggerHandlerFactory` |
| `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 |
| `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
26 changes: 16 additions & 10 deletions installation/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,24 +474,27 @@ The following instructions are intended for a Linux init system based on **syste
This will allow you to register openHAB as a service, so that it runs at startup and automatically restarts if openHAB crashes.
The service will be running with the privileges of the user "openhab" and expects the openHAB files under `/opt/openhab2`.
Create the file `/lib/systemd/system/openhab2.service` with the following content:
Create the file `/usr/lib/systemd/system/openhab2.service` with the following content:
```ini
[Unit]
Description=The openHAB 2 Home Automation Bus Solution
Documentation=http://docs.openhab.org
Description=openHAB 2 - empowering the smart home
Documentation=https://www.openhab.org/docs/
Documentation=https://community.openhab.org
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=openhab
Group=openhab
WorkingDirectory=/opt/openhab2
#EnvironmentFile=/etc/default/openhab2
ExecStart=/opt/openhab2/start.sh server
ExecStop=/bin/kill -SIGINT $MAINPID
#EnvironmentFile=-/etc/default/openhab2
ExecStart=/opt/openhab2/runtime/bin/karaf daemon
ExecStop=/opt/openhab2/runtime/bin/karaf stop
Restart=on-failure
SuccessExitStatus=0 143
[Install]
WantedBy=multi-user.target
Expand All @@ -512,10 +515,11 @@ sudo systemctl status openhab2.service
The output of `status` after a successful execution should be similar to:
```text
openhab2.service - The openHAB 2 Home Automation Bus Solution
Loaded: loaded (/lib/systemd/system/openhab2.service; enabled)
openhab2.service - openHAB 2 - empowering the smart home
Loaded: loaded (/usr/lib/systemd/system/openhab2.service; enabled)
Active: active (running) since Thu 2016-08-14 01:16:00 GMT; 18h ago
Docs: http://docs.openhab.org
Docs: https://www.openhab.org/docs/
https://community.openhab.org
```
#### Installing add-ons
Expand Down Expand Up @@ -573,7 +577,9 @@ To uninstall (or more precisely remove) openHAB 2 after being manually set up, t
sudo systemctl stop openhab2.service
sudo systemctl disable openhab2.service
sudo rm -rf /opt/openhab2/
sudo rm /usr/lib/systemd/system/openhab2.service
sudo rm /lib/systemd/system/openhab2.service
sudo systemctl daemon-reload
```
### File Locations
Expand Down

0 comments on commit ae6ae72

Please sign in to comment.