[OH3] Metadata "opposite" of expiration (Delay)

I’m looking to create a rule, that sends a command to a DIFFERENT item after 2/3/X minutes. I guess its the opposite of the existing “expire after” metadata, perhaps “Delay”.

I’m only just heading down this rabbit hole, so there’s probably already a snippet of code available on the forums that will get me there, but this wouldn’t be as native as a metadata option. Would this be feasible/suitable for consideration?

My use case is, turn on a power socket (Item == Switch), and then after X minutes “delay”, send a command to a different power socket (Item == Switch).

I was actually hoping I could fiddle this with the existing expire meta, but I can’t choose A N Other item to send the command to, suggesting the expire meta is purely to revert a one time command.


The standard solution to this problem is to use a rule with a timer. If you search the forum for createTimer or ‘timers’ you will find everything you need.

You can certainly incorporate a custom metadata namespace into this function if you wish to make one general rule that works for many different pairs and arbitrary delay times, but there’s not going to be any way to do this just with standard expire metadata and proxy items that’s simpler than a rule.

I’ve got plenty of Timer rules in old OH2 .rule format, can I achieve similar using OH3 native UI? I would assume the “script” area is where I need to be looking/working towards, within the OH3 rule editor…

Yep, (nearly) anything you can do in the written body of a rule in rules file you can do in the UI rule page when you Add ActionRun Script (don’t confuse that with the Scripts section of the settings, those are different). If you’re using Rules DSL then, for many rules, you can simply copy and paste the then section of the OH2 rule into the script editor. There are only a couple of critical changes to note:

  1. How OH handles time has changed so if your rule include now() or time manipulations then you will have to update all those pieces. Three are hundreds of posts on the forum at this point about how to do that if you search recent articles for ZonedDateTime
  2. If you happen to use executeCommandLine its syntax has changed and you can find info on that in the docs and in other threads.

An important difference in the context of Timers, UI DSL rules do not support the ‘global’ variables commonly used as Timer handles.