Iterate through timers without handle

Hi there,

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? :person_shrugging:

what happend to the shutdown event ?

I could have a shutdown Item that executes a rule that ends with starting a restart script.
But that requires OH to be functional which sometimes is not the case when you whish to restart it.

Create a switch item for every timer and set on/off :wink:
Greets

When the system runlevels were added there was no way to get a system shutdown event at that time. I think there’s still an issue open but it’s been open for quite some time.

You’d have the same problem with a system shutdown event. If OH isn’t functional enough to do that, it’s not functional enough to get and respond to a shutdown event.