I have a rule with different triggers, one of them is Time
when
Time cron "0 0 16 ? * * *" or
Item item1 changed or
Item item2 changed or
Item item3 changed
then
logInfo("Trigger", triggeringItemName)
switch(triggeringItemName) {
case "Time": {
//do stuff, does not work
}
case "item1": {
//do stuff, works
}
case "item2": {
//do stuff, works
}
}
Unfortunately the switch case works with all my items, except for the Time cron trigger. What am i doing wrong? The triggeringItemName is null. I am certain its because Time is not an Item. How to get the Time cron as a switch case trigger?
You can discover if there is no triggering Item, and infer it was a cron trigger.
You can acces the time ‘now’ in your rule, though its likely to be a few milliseconds after the cron by the time you can.