Identifying TimeOfDayTrigger within ecmascript

openHAB 3.0.2 Release Build
I would like to create an ecmascript rule that is triggered by several events. Within the rule I would like to parse the source trigger events. For the trigger type timer.TimeOfDayTrigger, event is not define and I can not use code such as if (event.itemName == '<someName>') {} to parse the trigger. How do I identify the trigger when the trigger is (in GUI speak) “Add Trigger”->“Time Event”->“at a fixed time of day”->?

Please note that event.itemName is working for core.ItemsStateChangeTigger triggers, but not for timer.TimeOfDayTrigger which does not define event in my environment.


  - id: "1"
      time: 10:50
    type: timer.TimeOfDayTrigger
conditions: []
  - inputs: {}
    id: "2"
      type: application/javascript
      script: >
        var logger =
        Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' +
        ctx.ruleUID);'rule running (event: ' + event + ')');
    type: script.ScriptAction

This code creates the error
2021-07-26 10:50:01.270 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'b0a16fe1a4' failed: ReferenceError: "event" is not defined in <eval> at line number 2
(note: line 2 refers to the logger line in the format of original code).

What can I test to identify a TimeOfDayTrigger?


You can probably do something like:

if(event === undefined) {
  // rule was triggered without an Item or Thing event (e.g. manually, cron, or time of day)
else {
  // rule was triggered by an Item or Thing event

You can’t specifically distinguish between a TimeOfDay trigger and a manual trigger, for example. But you should be able to tell the difference between an event trigger and a the rest.