Switch: Auto Off after X minutes

Hi All,

i want to achieve the following: when turning a switch on in HABpanel, i want to make sure it turn itself automatically off after a period of 15 minutes. It should also be possible to turn it off manuall within that period. And when turning the switch back on, timer should start form the beginning.
Background: i’m switching a simple valve for watering in the garden, however i forget sometimes to switch it off and too much water gets into the ground. Therefore it woul be great to have this feature in OH.
Every hint to achieve this is highly appreciated.


Hi Patrick,

you could use the “expire”-binding for that. just add it to the item-definition (after activating the binding, of course)

e.g. with a zwave-switch (from the example https://www.openhab.org/addons/bindings/expire1/#expire-binding)

Switch HallLight "HallLight [%s]" { zwave="3", expire="15m,command=OFF" }

what it does is simply sending the “OFF” command after 15min, if the item is ON. It resets after the item receives another “ON” command, meaning the timer is set anew to 15min - and it is deactivated if you switch it “OFF” before 15min ends.


Hi Thomas,

thank you ver much for the heads up on this binding. As i created all my things and items via Paper UI, will i be able to use this binding as well?



I don’t think so. expire is legacy OH1-binding and AFAIR, in PaperUI doesn’t let you add those stuff…
You have two choices, which come into my mind:

  1. use a items-file for only the switches you need to expire
  2. use a rule for that

ad 1)
just delete the item from PaperUI and make a item-file, which includes the expire-stuff

ad 2)
use a rule for that (again, this will be the “old” DSL rule file):

rule "shut off water pump"
    Item "YOURWATERPUMPITEM" changed
    if (YOURWATERPUMPITEM.state === ON) {
	// if water pump is started, set the timer for 15min
	if(tWaterPump !== null) {
		// if Timer is already running - cancel it
	tWaterPump= createTimer(now.plusMinutes(15), [|
		// after 15 min: shut off Waterpump
    } else if (YOURWATERPUMPITEM.state === OFF) {
	// if waterpump is shut off - cancel the timer (this should be triggered either when you manually switch it off or if the above timer switches it off

of course, you could use Next Generation Rules, but I didn’t use them yet, so you have to figure it out yourself! :wink: : https://www.openhab.org/docs/configuration/rules-ng.html#next-generation-rule-engine