diff --git a/README.md b/README.md index c88385ae0..c5b773377 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/rules/rules.js b/rules/rules.js index cdd6977ea..9bce0cd10 100644 --- a/rules/rules.js +++ b/rules/rules.js @@ -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 */ /** diff --git a/types/rules/rules.d.ts b/types/rules/rules.d.ts index f20d4a14e..d21fa87ca 100644 --- a/types/rules/rules.d.ts +++ b/types/rules/rules.d.ts @@ -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; }; diff --git a/types/rules/rules.d.ts.map b/types/rules/rules.d.ts.map index 108bebbf1..7016490ab 100644 --- a/types/rules/rules.d.ts.map +++ b/types/rules/rules.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../rules/rules.js"],"names":[],"mappings":";;;;;;;;;;;cAec,MAAM;;;;cACN,MAAM;;;;mBACN,MAAM;;;;qBACN,MAAM;;;;cACN,MAAM;;;;eACN,MAAM;;;;mBACN,MAAM;;;;gBACN,MAAM;;;;eACN,MAAM;;;;eACN,MAAM;;;;YACN,MAAM;;;;cACN,MAAM;;;;oBACN,MAAM;;;;UACN,MAAM;;;;eACN,MAAM;;;;iBACN,MAAM;;;;YACN,MAAM;;;;;;;;;mCAMT,WAAW;;;;;;;;UAKR,MAAM;;;;kBACN,MAAM;;;;cACN,cAAY,aAAa;;;;aACzB,YAAY;;;;SACZ,MAAM;;;;WACN,MAAM,EAAE;;;;gBACR,MAAM;;;;gBACN,OAAO;;AAqFrB;;;;;;;IAOI;AACJ,gCAHY,MAAM,GACJ,OAAO,CAUpB;AAED;;;;;;;;;IASI;AACJ,6BALY,MAAM,SACN,MAAM,SACN,OAAO,QAalB;AAED;;;;;;;;IAQI;AACJ,+BAJY,MAAM,GACJ,OAAO,CAQpB;AAED;;;;;;;IAOI;AACJ,gCAJY,MAAM,aACN,OAAO,QAQlB;AAED;;;;;;;;;;;;;;;;;IAiBI;AACJ,mCAJY,UAAU,YAiErB;AAED;;;;;;;;IAQI;AACJ,6CAJY,UAAU,YA0CrB"} \ No newline at end of file +{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../rules/rules.js"],"names":[],"mappings":";;;;;;;;;;;cAec,MAAM;;;;cACN,MAAM;;;;mBACN,MAAM;;;;qBACN,MAAM;;;;cACN,MAAM;;;;eACN,MAAM;;;;mBACN,MAAM;;;;gBACN,MAAM;;;;eACN,MAAM;;;;eACN,MAAM;;;;YACN,MAAM;;;;cACN,MAAM;;;;oBACN,MAAM;;;;UACN,MAAM;;;;eACN,MAAM;;;;iBACN,MAAM;;;;gBACN,MAAM;;;;YACN,MAAM;;;;;;;;;mCAMT,WAAW;;;;;;;;UAKR,MAAM;;;;kBACN,MAAM;;;;cACN,cAAY,aAAa;;;;aACzB,YAAY;;;;SACZ,MAAM;;;;WACN,MAAM,EAAE;;;;gBACR,MAAM;;;;gBACN,OAAO;;AAqFrB;;;;;;;IAOI;AACJ,gCAHY,MAAM,GACJ,OAAO,CAUpB;AAED;;;;;;;;;IASI;AACJ,6BALY,MAAM,SACN,MAAM,SACN,OAAO,QAalB;AAED;;;;;;;;IAQI;AACJ,+BAJY,MAAM,GACJ,OAAO,CAQpB;AAED;;;;;;;IAOI;AACJ,gCAJY,MAAM,aACN,OAAO,QAQlB;AAED;;;;;;;;;;;;;;;;;IAiBI;AACJ,mCAJY,UAAU,YAiErB;AAED;;;;;;;;IAQI;AACJ,6CAJY,UAAU,YA0CrB"} \ No newline at end of file