Alarm Clock Rule


A rule template that will schedule the execution of another rule based on the state of a DateTime Item. This rule makes a good companion to use with the Android App’s Alarm Item but it can be used with any DateTime Item.

The logger is named org.openhab.model.script.rules_tools.Alarm Clock


Parameter Type Required Description
Alarm Time Item DateTime Item X Item that contains the date and time to run the script.
Script to Call Rule ID X The Rule or Script to call at the indicated date and time.

If you’ve more than one DateTime Item you can create more than one instance of this rule from the template, one for each Item. They can call the same Script or a different Script as desired.

Language: Nashorn JavaScript (default built into OH 3.x)


  • The Alarm Time must be in the future or else no alarm will be set and any existing alarm will be cancelled.
  • The date as well as the time is used. To set a recurring alarm one must have a separate rule to move the Item’s date forward to the new day.
  • If using the Android App and SleepAsAndroid, the alarm time will not be posted until a little before the alarm is set to go off.


Version 0.2

  • bug fixes
  • added a trigger to run the rule at system started so if OH restarts the alarm timer is rescheduled

Version 0.1

  • initial release



question, how can i set this rule to turn on a device with a scheduled date/time and make it running for XXmins?

i’ve copied your rule on my test environment and i see under “when” i can set the setpoint item that could be my runtime (30 mins, 1 hour…) but i would like to have the possibility to chose a weekday to run this and also to to chose the device to turn on/off from a list.
can you help with this to make your script really powerful?

That is literally what the rule does. You have a DateTime Item. At the date and time of that Item, the above rule will run a Script rule that you write.

If you want it to turn on Switch Foo for 60 minutes on Thursday at 09:00, set the DateTime Item to 09:00 on Thursday and write your Script Rule to send an ON command to Foo, wait an hour and then send an OFF command to Foo.

Then set the DateTime Item to the week day that you want it to run.

NOTE: This rule does not reschedule the “alarm”. It is up to you to write something that changes the DateTime Item to move it forward to the next date and time that the alarm should go off.

The only thing this rule template does is schedule a Script to run (a Script you have to write) at a DateTime specified by the state of a DateTime Item. Nothing more.

The features you are asking for are not implemented by this rule and since this rule was written to primarily work in conjunction with the Android app’s Alarm Item feature (i.e. the app will publish the date and time of the next scheduled alarm scheduled on the phone) there really is no way I can add the features you are asking for without breaking this rule template’s primary purpose.