Dynamic rule execution timing

Hi *,

is there a way to execute a script on a time determined by a dynamically set DateTime item?

Currently I have a DateTime Item, that gets updated to the specific time I’d like to run some logic. The only idea that came to mind was a cron job running every five minutes that compares the current time to the time of the object… This does not seem like a great way to do it, or is it?

Thanks in advance!

Just time or time and date?

You might be able to use Alarm Clock Rule and To Today. See Creating Capabilities with Rule Templates: Time of Day for using those together.

But they assume that either the date is part of the DateTime or if all you care about is the time that the date can be set using To Today.

Thanks for the hint. I guess the solution I’m going to use will be the ScriptExecution.createTimer() one.
Do you have any insight in how this is in turn implemented on OpenHab side?

Well, the point of my post and the links is to show you you don’t have to implement anything at all. Just install the rule templates from the Marketplace and configure them to use your Item and the UID of the rule you want to have called that that time.

The To Today rule template is also installable from the marketplace and if you tag that Item with the time, the To Today rule will move that Item’s DateTime date to today’s date around midnight, triggering the Alarm Clock rule to recreate the Timer to run the script for the new day.

It’s all on the openHAB side. I don’t understand the question.