I am using multiple triggers to fire a rule, “system started”, cron and Member of xx changed,
How can i check waht triggers the rule? Any idea?
Would appreciate tips and hints.
Running on openHAB 4.3.6-1 on Debian bookworm
Thanx in advance
I am using multiple triggers to fire a rule, “system started”, cron and Member of xx changed,
How can i check waht triggers the rule? Any idea?
Would appreciate tips and hints.
Running on openHAB 4.3.6-1 on Debian bookworm
Thanx in advance
I’m not aware of a direct option.
You can test if the implicit var triggeringItem does exist to get the Member-Part sorted out, but there is no implicit var for cron vs. system started.
Is this for rulesdsl?
Thanks Udo for your reply, this is the way i currently do it, but i have just a few small changes between the three options and i do not like to have three rules for it. More ideas?
Yes i am still using the old method, really interested in the Python stuff of V5.0 ![]()
I suppose this can be added, but is it worth doing so?
The info is already in the event I think since there is a type property on the event Object. Cron triggered rules will have that set to TimerEvent. The only time event.type isn’t there is when one rule calls another in which case no event Object exists at all.
It is a really handy feature.
Whether this is a feature that would be useful to add to Rules DSL though is a different question I can’t answer. I’d like to see users move away from Rules DSL entirely but some people still really like it for some reason.
Note you can get to event.type from Blockly too (it’s in the “contextual info” block). It’s really only Rules DSL that doesn’t have it.
For the record, some of the types you will see (this is not an exhastive list:
| Trigger | Type |
|---|---|
| system started or runlevel | StartlevelEvent |
| cron, time of day, time is Item | TimerEvent |
| manually run | ExecutionEvent |
| event Channel | ChannelTriggeredEvent |
| Thing status | ThingStatusInfoChangedEvent (I think) |
| Item changed | ItemChangedEvent |
| Item updated | ItemStateUpdatedEvent |
| Item commanded | ItemCommandEvent |
There are more but these cover the basics. Depending on the type, the event Object will have additional information in the payload which is a JSON formatted String of key/valkue pairs. For example, the TimerEvent from a cron expression will have a “cronExpression” property in the payload. In JS you can get at that information like this:
console.info(JSON.parse(event.getPayload())["cronExpression"]);
or if you are using a file based rule the helper library intercepts the Java event Object and extracts this information for you. See JavaScript Scripting - Automation | openHAB.
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.