Skip to content

Commit

Permalink
[rules] Improve docs of file-based event object
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 committed Dec 9, 2023
1 parent ca868fe commit ac6bb4c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1322,10 +1322,15 @@ This table gives an overview over the `event` object:
| `time` | `TimeOfDayTrigger` | Time of day value of the trigger | N/A |
| `eventType` | all except `PWMTrigger`, `PIDTrigger` | Type of event that triggered event (change, command, triggered, update, time) | N/A |
| `triggerType` | all except `PWMTrigger`, `PIDTrigger` | Type of trigger that triggered event | N/A |
| `eventClass` | all | Java class name of the triggering event | N/A |
| `module` | all | (user-defined or auto-generated) name of trigger | N/A |
All properties are typeof `string`.
Please note that when using `GenericEventTrigger`, the available properties depend on the chosen event types.
It is not possible for the openhab-js library to provide type conversions for all properties of all openHAB events, as those are too many.
In case the event object does not provide type-conversed properties for your chosen event type, use the `payload` property to gain access to the event's (Java data type) payload.
**NOTE:**
`Group****Trigger`s use the equivalent `Item****Trigger` as trigger for each member.
Time triggers do not provide any event instance, therefore no property is populated.
Expand Down
3 changes: 2 additions & 1 deletion rules/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
* @property {string} time for {@link triggers.TimeOfDayTrigger}: time of day value of the trigger
* @property {string} eventType for all triggers except {@link triggers.PWMTrigger}, {@link triggers.PIDTrigger}: Type of event that triggered event (change, command, time, triggered, update, time)
* @property {string} triggerType for all triggers except {@link triggers.PWMTrigger}, {@link triggers.PIDTrigger}: Type of trigger that triggered event
* @property {string} eventClass for all triggers: Java class name of the triggering event
* @property {string} module (user-defined or auto-generated) name of trigger
* @property {*} payload for most triggers
* @property {*} payload if provided by event: payload of event in Java data types
*/

/**
Expand Down
6 changes: 5 additions & 1 deletion types/rules/rules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,16 @@ export type EventObject = {
* for all triggers except {@link triggers.PWMTrigger }, {@link triggers.PIDTrigger }: Type of trigger that triggered event
*/
triggerType: string;
/**
* for all triggers: Java class name of the triggering event
*/
eventClass: string;
/**
* (user-defined or auto-generated) name of trigger
*/
module: string;
/**
* for most triggers
* if provided by event: payload of event in Java data types
*/
payload: any;
};
Expand Down
2 changes: 1 addition & 1 deletion types/rules/rules.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ac6bb4c

Please sign in to comment.