One Item - Multiple expirations

Hi, I have a FGWP102 wallplug that I want to turn on and have it expire after a given time.
My problem is that I want to have the option to select different times for expire.

What I want to do is to have different “On” triggers that would expire after a set time.

Switch = ON-30 (expire and turn off after 30min)
Switch = ON-60 (expire and turn off after 60min)
Switch = ON-90 (expire and turn off after 90min)

My problem is that if I turn on the switch for ON-90 it also triggers the expire timer for both of the other switches. Meaning it turns off after only 30 min.

Is there any solution to this that I’m missing?

  1. The most straight forward would be to use a rule and a Timer in a Script Action instead of Expire.

  2. Alternatively make your ON-30 et al Items be proxy Items and create a rule that translates the ON/OFF to the “raw” Item that is the only one linked to the Channel.

Rich’s solutions are probably easier, but I have third option which I use in the few cases where I need expiration at different times: You can write a rule that modifies the expiration metadata to set the appropriate timeout value.

1 Like

I forgot about that approach. I wonder if that could be turned into rule template.

My JS Scripting is broken right now but maybe I can take a look into doing that next week.

2 Likes

How would I create such a rule?

I’m using Openhab 3.3.0 and I’m not using any textual files. Just the web-interface.

Which one? At least three approaches using rules have been mentioned. But a rule is a rule, text based or UI based. The Getting Started Tutorial has a bunch of pages on getting started writing Rules in the UI.

Ok, for anyone else that has the same trouble figuring out how to accomplish this.
This is what I did.

I went to Settings → Things, and created a Switch item for my wallplug (Wallplug_switch)
I went to Settings → Items, and created two switches (30min_switch and 60min_switch) that is not linked to the wallplug switch item.
For each of these switches i added Metadata → Expiration Timer, and set the timeout to send command OFF.

Then I went into Settings → Rules and created two rules for each button, one for the ON command and one for the OFF command.

I.e when item 30min_switch recieve command ON then send command ON to Wallplug_switch
I.e when item 30min_switch recieve command OFF then send command OFF to Wallplug_switch

You could get away with two rules total. Trigger the ON rule when either the 30 minutes switch or the 60 minutes switch receive an ON command. One rule can have more than one trigger and you want to do the same thing in both cases. Repeate for the OFF rules.

Another alternative is to put the timer Items into a Group and trigger the rule using a member of the Group receives command ON.

Sidenote, I hope those are not literally the names of your items. Item names can not start with a number. This is enforced in newer versions of OH.