I use OH3.4 and textual DSL rules.
I would like to send an email with a list of running timers on shutdown.
But for better code maintinability I would love to do so without the handle. Is there a way to iterate through all timers by e.g. using some getItemByName(“Timer*”) function ?
Or alternatively, combine all Timers in a group ?
No, if you lose the handle you lose access to the Timer. Timers exist in the context of the Rule so even if there were some sort of registry of Timers, you’d only get access to the Timers created by the one rule.
There is a new sharedCache registry that all Rules can use to share data between each other, but I don’t think it’s available in Rules DSL yet. If you put all your timers in there, you can pull them all back out. But of course, that means you’ve not thrown away the handles, you’ve stored them somewhere.
Now your problem will be there is no System shutdown event any more so how to know when OH is shutting down?