Skip to content

Commit 0f712ff

Browse files
authored
README: Improvements to UI event object docs (#444)
Closes #316 . Signed-off-by: Richard Koshak <rkoshak@users.noreply.github.com>
1 parent a539e28 commit 0f712ff

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,11 @@ See [openhab-js](https://openhab.github.io/openhab-js) for a complete list of fu
138138
### UI Event Object
139139

140140
**NOTE**: Note that `event` object is different in UI based rules and file based rules! This section is only valid for UI based rules. If you use file based rules, refer to [file based rules event object documentation](#event-object).
141-
Note that `event` object is only available when the UI based rule was triggered by an event and is not manually run!
142-
Trying to access `event` on manual run does not work (and will lead to an error), use `this.event` instead (will be `undefined` in case of manual run).
141+
Note that `event` object is only available when the UI based rule was triggered by an event and is not called from another rule!
142+
Trying to access `event` in this case does not work and will lead to an error. Use `this.event` instead (will be `undefined` when it does not exist).
143143

144144
When you use "Item event" as trigger (i.e. "[item] received a command", "[item] was updated", "[item] changed"), there is additional context available for the action in a variable called `event`.
145+
When a rule is triggered, there is additional context available for the action in a variable called `event`.
145146

146147
This table gives an overview over the `event` object for most common trigger types:
147148

@@ -152,8 +153,10 @@ This table gives an overview over the `event` object for most common trigger typ
152153
| `itemCommand` | sub-class of [org.openhab.core.types.Command](https://www.openhab.org/javadoc/latest/org/openhab/core/types/command) | `[item] received a command` | Command that triggered event | `receivedCommand` |
153154
| `itemName` | string | all | Name of Item that triggered event | `triggeringItem.name` |
154155
| `type` | string | all | Type of event that triggered event (`"ItemStateEvent"`, `"ItemStateChangedEvent"`, `"ItemCommandEvent"`, ...) | N/A |
156+
| `event` | string | channel based triggeres | Event data published by the triggering channel. | `receivedEvent` |
157+
| `payload` | JSON formatted string | all | Any additional information provided by the trigger not already exposed. "{}" there is none. | N/A |
155158

156-
Note that in UI based rules `event.itemState`, `event.oldItemState`, and `event.itemCommand` are Java types (not JavaScript), and care must be taken when comparing these with JavaScript types:
159+
Note that in UI based rules `event`, and therefore everything carried by `event` are Java types (not JavaScript). Care must be taken when comparing these with JavaScript types:
157160

158161
```javascript
159162
var { ON } = require("@runtime")

0 commit comments

Comments
 (0)